import java.util.*;
class Solution {
public int[] solution(int[] array, int[][] commands) {
int[] answer = new int[commands.length];
int k = 0;
for(int i=0;i<commands.length;i++){
int[] command = commands[i];
int start = command[0];
int end = command[1];
int sequence = command[2];
ArrayList<Integer> arr = new ArrayList<>();
for(int a=start-1;a<end;a++){
arr.add(array[a]);
}
Collections.sort(arr);
answer[k++] = arr.get(sequence-1);
}
return answer;
}
}
콜렉션 소팅 함수 에다 자꾸 배열 소팅 함수를 쓰고 난리다. 나참