프로그래머스 - 최소직사각형

youngkyu MIn·2023년 10월 31일

문제링크 - 프로그래머스 - 최소직사각형

import java.util.*;

public class Solution {
    public int solution(int[][] sizes) {
        int maxWidth = 0;
        int maxHeight = 0;

        for (int[] size : sizes) {
            int tempMax = Math.max(size[0], size[1]);
            int tempMin = Math.min(size[0], size[1]);

            maxWidth = Math.max(maxWidth, tempMax);
            maxHeight = Math.max(maxHeight, tempMin);
        }

        return maxWidth * maxHeight;
    }
}
profile
한 줄 소개

0개의 댓글