PS/프로그래머스

[JS]최소직사각형

returnzero 2022. 7. 22. 13:12
function solution(sizes) {
    var answer = 0;
    let maxone=0;
    let maxtwo=0;
    sizes.forEach(e=>{
        e.sort((a,b)=>a-b);
        // console.log(e);
    })
    sizes.forEach(e=>{
        maxone= Math.max(e[0],maxone);
        maxtwo= Math.max(e[1],maxtwo);
    })
    // console.log(maxone,maxtwo);
    answer=maxone*maxtwo;
    return answer;
}