슈콩

[프로그래머스] 최소직사각형 본문

Algorithms/Programmers

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

shukong 2025. 10. 31. 23:56

 

 

 

[문제]

https://school.programmers.co.kr/learn/courses/30/lessons/86491#qna

 

프로그래머스

SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프

programmers.co.kr

 

 

 

[소스 코드]

class Solution {
    public int solution(int[][] sizes) {
        int answer = 0;
        int row = 0;
        int col = 0;
        
        for(int i=0;i<sizes.length;i++){
            int w = Math.min(sizes[i][0],sizes[i][1]);
            int h = Math.max(sizes[i][0],sizes[i][1]);
            row = Math.max(w,row);
            col = Math.max(h,col);
        }
        answer = row * col;
        return answer;
    }
}