프로그래머스 알고리즘/1단계
(프로그래머스 JS)K번째 수
naeunchan
2021. 2. 24. 17:02
728x90
반응형
programmers.co.kr/learn/courses/30/lessons/42748
코딩테스트 연습 - K번째수
[1, 5, 2, 6, 3, 7, 4] [[2, 5, 3], [4, 4, 1], [1, 7, 3]] [5, 6, 3]
programmers.co.kr
function solution(array, commands) {
let answer = [];
commands.filter((val, index) => {
answer.push(
array.slice(commands[index][0] - 1, commands[index][1]).sort((a, b) => a - b)[
commands[index][2] - 1
]
);
});
return answer;
}
728x90
반응형