プログラマ-k個の数字
594 ワード
import java.util.*;
class Solution {
public int[] solution(int[] array, int[][] commands) {
int[] answer= new int[commands.length];
int n=0;
for(int i=0; i<commands.length; i++){
int k=0;
int[] list=new int[commands[i][1]-commands[i][0]+1];
for(int j=commands[i][0]; j<=commands[i][1]; j++ ){
list[k++]=array[j-1];
}
Arrays.sort(list);
answer[n++]=list[commands[i][2]-1];
}
return answer;
}
}
Reference
この問題について(プログラマ-k個の数字), 我々は、より多くの情報をここで見つけました https://velog.io/@c65621/프로그래머스-k번째-수テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol