인생일지

반응형

 

import java.util.*;

class Solution {
    public int[] solution(int[] array, int[][] commands) {
        int[] answer = new int[commands.length];
        
        for(int i = 0; i < commands.length; i++) {
            int a = commands[i][0];
            int b = commands[i][1];
            int c = commands[i][2];
            
            Integer[] dummyA = new Integer[b - a + 1];
            int k = 0;
            
            for(int j = a -1; j < b; j++) {
                dummyA[k] = array[j];
                k++;
            }
            Arrays.sort(dummyA);
            answer[i] = dummyA[c-1];
        }
        return answer;
    }
}

 

문제출저:

https://programmers.co.kr/learn/courses/30/lessons/42748

반응형

공유하기

facebook twitter kakaoTalk kakaostory naver band
loading