JavaScript
[프로그래머스 Lv.1] 최소직사각형
어느새벽
2024. 10. 31. 00:35
반응형
function solution(sizes) {
const width = [];
const height = [];
for(let i = 0; i < sizes.length; i++) {
const max = Math.max(sizes[i][0], sizes[i][1]);
const min = Math.min(sizes[i][0], sizes[i][1]);
width.push(max);
height.push(min);
}
return Math.max(...width) * Math.max(...height);
}

반응형