최소직사각형

han.user();·2023년 4월 18일
0

프로그래머스

목록 보기
85/87
post-thumbnail

import java.util.Arrays;

class Solution {
    public int solution(int[][] sizes) {
        int maxW = 0;
        int maxH = 0;

        for (int i = 0; i < sizes.length; i++) {
            int[] size = sizes[i];
            Arrays.sort(size);

            int w = size[0];
            int h = size[1];

            if (w > maxW) {
                maxW = w;
            }

            if (h > maxH) {
                maxH = h;
            }
        }

        return maxW * maxH;
    }
}
profile
I'm still hungry.

0개의 댓글