// 풀이 1
function solution(sizes) {
var answer = 0;
let max = []
let min = []
for (let x of sizes) {
max.push(Math.max(...x))
min.push(Math.min(...x))
}
return Math.max(...max) * Math.max(...min);
}
// 풀이 2
function solution(sizes) {
const [hor, ver] = sizes.reduce(([h, v], [a, b]) => [Math.max(h, Math.max(a, b)), Math.max(v, Math.min(a, b))], [0, 0])
return hor * ver;
// 풀이 3
function solution(sizes) {
let w = 0;
let h = 0;
sizes.forEach(s => {
const [a, b] = s.sort((a,b) => a-b);
if (a > h) h = a;
if (b > w) w = b;
});
return w * h;
}
// 풀이 4
function solution(sizes) {
const rotated = sizes.map(([w, h]) => w < h ? [h, w] : [w, h]);
let maxSize = [0, 0];
rotated.forEach(([w, h]) => {
if (w > maxSize[0]) maxSize[0] = w;
if (h > maxSize[1]) maxSize[1] = h;
})
return maxSize[0]*maxSize[1];
}