-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPro86491.java
More file actions
36 lines (31 loc) · 1004 Bytes
/
Pro86491.java
File metadata and controls
36 lines (31 loc) · 1004 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package algorithm_study.programers;
// 최소직사각형 - https://school.programmers.co.kr/learn/courses/30/lessons/86491
public class Pro86491 {
public int solution(int[][] sizes) {
int answer = 0;
int maxW = 0;
int maxH = 0;
for (int i = 0; i < sizes.length; i++) {
if (sizes[i][0] < sizes[i][1]) {
int temp = sizes[i][0];
sizes[i][0] = sizes[i][1];
sizes[i][1] = temp;
}
maxW = Math.max(maxW, sizes[i][0]);
maxH = Math.max(maxH, sizes[i][1]);
}
answer = maxW * maxH;
return answer;
}
}
class Pro86491Answer {
public int solution(int[][] sizes) {
int length = 0, height = 0;
for (int[] card : sizes) {
length = Math.max(length, Math.max(card[0], card[1]));
height = Math.max(height, Math.min(card[0], card[1]));
}
int answer = length * height;
return answer;
}
}