개발공부/코딩테스트 연습문제
[프로그래머스] 최소직사각형
ku-na
2022. 1. 11. 10:44
문제 설명과 제한사항

풀이
class Solution {
public int solution(int[][] sizes) {
int longSize = 0;
int shortSize = 0;
for(int[] size : sizes){
longSize = Math.max(longSize, Math.max(size[0],size[1]));
shortSize = Math.max(shortSize, Math.min(size[0],size[1]));
}
return longSize * shortSize;
}
}
++
사고력 문제라더라.. 풀이 이해하니까 바로 풀리긴 했는데 처음 문제 봤을떄는 당황 조매함!