fullfish 2022. 4. 19. 21:39

아이디어 

slice와 sort를 쓰자

 

코드

function solution(array, commands) {
  let result = [];
  for (let i = 0; i < commands.length; i++) result.push(array.slice(commands[i][0] - 1, commands[i][1]).sort((a, b) => a - b)[commands[i][2] - 1]);
  return result;
}