class Solution {
public int solution(int[][] sizes) {
// int garo = 0;
// int sero = 0;
// for(int[] list : sizes){
// if(list[1] > list[0]){
// if(list[1] > garo){
// garo = list[1];
// }
// if(list[0] > sero){
// sero = list[0];
// }
// }else {
// if(list[0] > garo){
// garo = list[0];
// }
// if(list[1] > sero){
// sero = list[1];
// }
// }
// }
// return garo*sero; // 기존 코드
// 새로 만든 코드
int maxGaroT = Arrays.stream(sizes).filter(ints -> ints[0] < ints[1])
.mapToInt(row -> row[1])
.max()
.orElse(Integer.MIN_VALUE);
int maxSeroT = Arrays.stream(sizes).filter(ints -> ints[0] < ints[1])
.mapToInt(row -> row[0])
.max()
.orElse(Integer.MIN_VALUE);
int maxGaroR = Arrays.stream(sizes).filter(ints -> ints[0] >= ints[1])
.mapToInt(row -> row[0])
.max()
.orElse(Integer.MIN_VALUE);
int maxSeroR = Arrays.stream(sizes).filter(ints -> ints[0] >= ints[1])
.mapToInt(row -> row[1])
.max()
.orElse(Integer.MIN_VALUE);
return Math.max(maxGaroT, maxGaroR) * Math.max(maxSeroT, maxSeroR);
}
}