[프로그래머스] K번째 수

Salki·2021년 3월 1일
0

알고리즘

목록 보기
8/10
function solution(array, commands) {
    const answer = [];
    
    for(let i=0; i<commands.length; i++)
    {
        let tmpArr = array.slice(commands[i][0]-1,commands[i][1]);
        tmpArr.sort(function(a,b){return a-b;});
        answer.push(tmpArr[commands[i][2]-1]);
    }
    
    return answer;
}
profile
실력있는 개발자로 거듭나기까지..

0개의 댓글