프로그래머스/Lv. 1 - 자바
최소직사각형
EH헌
2024. 2. 6. 00:27
풀이
class Solution {
public int solution(int[][] sizes) {
int wm = 0;
int hm = 0;
int answer = 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;
}
}
for(int j=0; j<sizes.length; j++){
if(wm < sizes[j][0]){
wm = sizes[j][0];
}
if(hm < sizes[j][1]){
hm = sizes[j][1];
}
answer = wm * hm;
}
return answer;
}
}
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
먼저 가로 세로 중 가로 < 세로 되게끔 바꾸고 결과 구하기