๋ฌธ์ ๐ฝ
https://school.programmers.co.kr/learn/courses/30/lessons/150370
๋ค๋ฅธ์ฌ๋ ํ์ด ๐ฝ
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];
}
๋ดํ์ด๐ฝ
1. ์ฑ๊ณต โญ
function solution(sizes) {
let [wArr, hArr] = [[],[]]
sizes.forEach((size)=>{
wArr.push(Math.max(...size))
hArr.push(Math.min(...size))
})
return Math.max(...wArr)*Math.max(...hArr)
}
๋๋์ ๐ฝ
sizes.forEach((size)=>{
wArr.push(Math.max(...size))
hArr.push(Math.min(...size))
})
โฒ ์ ๋ถ๋ถ์
sizes.forEach(([w,h])=>{
wArr.push(Math.max(w,h))
hArr.push(Math.min(w,h))
}
์ด๋ฐ์์ผ๋ก ์์ฑํ๋ฉด ์ฝ๋ ๊ฐ๋
์ฑ์ด ๋ ์ข์ ๊ฒ ๊ฐ๋ค