[Algorithm] 14 week(4.11 ~ 4.17) 2/3

Dev_min·2022년 4월 13일
0

algorithm

목록 보기
45/157

1051. Height Checker

var heightChecker = function(heights) {
    let count = 0;
    const sortedHeights = [...heights].sort((a, b) => a - b);
    
    heights.forEach((height, index) => {        
        if(height !== sortedHeights[index]){
            count++;
        }
    });
    
    return count;
};
profile
TIL record

0개의 댓글