https://programmers.co.kr/learn/courses/30/lessons/42748
굉장히 쉬운 문제이나 javascript의 sort에 조건을 추가해주지 않으면 특정 테스트케이스가 통과되지 않는다.
function solution(array, commands) {
var answer = [];
for(const command of commands){
let temp = [...array];
let [i,j,k] = command;
temp = temp.slice(i-1,j);
temp.sort((a,b)=>a-b);
answer.push(temp[k-1])
}
return answer;
}
'개발 > 알고리즘' 카테고리의 다른 글
[Programmers] 나누어떨어지는 숫자 배열 (0) | 2020.08.30 |
---|---|
[Programmers] 2016 (0) | 2020.08.30 |
[Programmers] 모의고사 (0) | 2020.08.30 |
[Programmers] 완주하지 못한 선수 (0) | 2020.08.29 |
[Programmers] 크레인 인형뽑기 (0) | 2020.08.29 |