프로그래머스 K번째의 수

Siwoo Pak·2021년 12월 22일
0

풀이

function solution(array, commands) { 
    
    return commands.map(command => {
        const [start,end,index] = command;
        let sortedSliceArr = array.slice(start-1,end).sort((a,b) => a-b);
        return sortedSliceArr[index-1];
    });
   
}
profile
'하루를 참고 인내하면 열흘을 벌 수 있고 사흘을 참고 견디면 30일을, 30일을 견디면 3년을 벌 수 있다.'

0개의 댓글