-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWeek9.java
More file actions
25 lines (23 loc) · 713 Bytes
/
Week9.java
File metadata and controls
25 lines (23 loc) · 713 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
package Programmers.Weekly;
import java.util.*;
class Solution {
public int solution(int[][] sizes) {
int maxWidth = 0;
int[] heightList = new int[sizes.length];
for (int i = 0; i < sizes.length; i++) {
int minTemp = 1001;
for (int j = 0; j < 2; j++) {
if (maxWidth < sizes[i][j]) {
maxWidth = sizes[i][j];
}
if (minTemp > sizes[i][j]) {
minTemp = sizes[i][j];
}
}
heightList[i] = minTemp;
}
Arrays.sort(heightList);
int maxHeight = heightList[sizes.length - 1];
return maxWidth * maxHeight;
}
}