import java.util.*;
class Solution {
public int[] solution(int[] array, int[][] commands) {
// answer을 commands 길이의 배열로 생성
int[] answer = new int[commands.length];
// commands의 길이만큼 반복
for (int x = 0; x < commands.length; x++) {
// 임시 배열 temp 생성하고 Array 함수를 통해 array의 commands에 입력된
// 숫자를 start와 end 길이로 자름
int[] temp = Arrays.copyOfRange(array, commands[x][0]-1, commands[x][1]);
// Array 메소드로 temp를 오름차순 정렬
Arrays.sort(temp);
// answer[x]에 temp의 commands[x][2]에 있는 숫자 인덱스-1 번째에 위치한 숫자를 입력
answer[x] = temp[commands[x][2]-1];
}
return answer;
}
}