반응형
import java.util.Arrays;
class Solution {
public int[] solution(int[] array, int[][] commands) {
int[] answer = {};
int cmdCount = commands.length;
answer = new int[cmdCount];
for(int i=0; i<cmdCount; i++){
int[] arr = Arrays.copyOfRange(array, commands[i][0]-1, commands[i][1]);
Arrays.sort(arr);
answer[i] = arr[commands[i][2]-1];
}
return answer;
}
}
무난무난 하다!... 사실 정렬알고리즘 자체를 구현하지 않아서......
반응형
'알고리즘' 카테고리의 다른 글
완전탐색-카펫(lv2) (0) | 2022.07.26 |
---|---|
정렬알고리즘 - Lv2(가장 큰수)-1(completed) (0) | 2021.07.26 |
탐욕알고리즘 - Lv2(조이스틱)-1(completed) (0) | 2021.07.14 |
탐욕알고리즘 - Lv1(체육복)-2 (0) | 2021.07.12 |
탐욕알고리즘 - Lv1(체육복) (0) | 2021.07.04 |