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

sundays·2022년 8월 17일
0

문제

class Solution {
    public int solution(int[][] sizes) {
        int answer = 0;
		int min_heigth = 0;
		int min_width = 0;
		for (int i = 0 ;i < sizes.length; i++) {
			int[] s = sizes[i];
			if (s[0] > s[1]) {
				min_heigth = Math.max(min_heigth, s[0]);
				min_width = Math.max(min_width, s[1]);
			} else {
				min_heigth = Math.max(min_heigth, s[1]);
				min_width = Math.max(min_width, s[0]);
			}
		}
        
        answer = min_width * min_heigth;
        return answer;
    }
}

문제는 쉬운데 인덱스가 계속 오타나서 틀렸음

profile
develop life

0개의 댓글