코드를 입력하세요
function solution(sizes) {
const newArray = []
for (let size of sizes) {
if (size[0] > size[1]) {
newArray.push(size)
} else {
newArray.push([size[1], size[0]])
}
}
const left = []
const right = []
for (let item of newArray) {
left.push(item[0])
right.push(item[1])
}
return Math.max(...left) * Math.max(...right)
}
=> 정렬 활용하면 더 깔끔한 코드가 나왔을 텐데.. 좀 아쉽다는 생각이 들었다..