uploaded at 2022. 12. 17. 오전 4:03:27

This commit is contained in:
rl544
2022-12-17 04:03:30 +09:00
parent abf08b41ba
commit 5271679909
+20
View File
@@ -0,0 +1,20 @@
// [문제 링크]: https://school.programmers.co.kr/learn/courses/30/lessons/42748
import java.util.*;
import java.util.stream.IntStream;
class Solution {
public int[] solution(int[] array, int[][] commands) {
int[] answer = new int[commands.length];
int index = 0;
for(int[] a : commands){
int i = a[0];
int j = a[1];
int k = a[2];
int[] res = IntStream.range(i, j + 1)
.map(o -> array[o-1]).sorted()
.toArray();
answer[index++] = res[k-1];
}
return answer;
}
}