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

Kong-al·2022년 10월 16일
0

22.10.15 D-78

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

[ 답안 ]

class Solution {
    public int solution(int[][] sizes) {
        int answer = 0 ;
        int max_w = 0; 
        int max_h = 0; 
        
        for(int i = 0 ; i < sizes.length; i++){ 
            if(sizes[i][0] < sizes[i][1]){
                int a = sizes[i][0];
                sizes[i][0] = sizes[i][1];
                sizes[i][1] = a;
            }
            if(max_w < sizes[i][0]) max_w = sizes[i][0]; 
            if(max_h < sizes[i][1]) max_h = sizes[i][1];
        }
        
        answer = max_w * max_h; 
        return answer;
    
    
}}
profile
웹개발 공부중!(❁´◡`❁)

0개의 댓글