본문으로 바로가기
728x90
반응형

문제

 

 

반응형

풀이

 

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
import java.util.Arrays;
class Solution {
    public int[] solution(int[] array, int[][] commands) {
        int[] answer = new int[commands.length];    
        
        for(int i=0; i<commands.length; i++) {      //copyOfRange 사용
            int[] temp = Arrays.copyOfRange(array, commands[i][0]-1, commands[i][1]);
            Arrays.sort(temp);                      //정렬
            answer[i] = temp[commands[i][2]-1];
        }
        return answer;
    }
}
cs

 

728x90
반응형