[프로그래머스 문제풀이30]최소직사각형 자바스크립트

이ᄏᄋ·2021년 9월 28일
0
function solution(sizes) {
    var answer = 0;
    let maxWidth=0;
    let maxHeight=0;
    for(const size of sizes){
        size.sort((a,b)=>b-a); 
        if(maxWidth <size[0])
            maxWidth=size[0];
        if(maxHeight<size[1])
            maxHeight=size[1];
    }
    answer=maxWidth*maxHeight
    return answer;
}

문제 제목에 답이 있음

profile
미쳤다.

0개의 댓글