EH헌 2024. 2. 6. 22:56

풀이

import java.util.*; 

class Solution {
    public int[] solution(int[] array, int[][] commands) {
        int[] answer = new int[commands.length];

		for (int i = 0; i < answer.length; i++) {
		
		int ii = commands[i][0];
		int jj = commands[i][1];
		int kk = commands[i][2];
		
		//				            배열명, 시작인덱스, 끝인덱스+1
		int[] temp = Arrays.copyOfRange(array, ii-1, jj);
		
		Arrays.sort(temp);
		
		answer[i] = temp[kk-1];
		
		}
	return answer;
    }
}

 

 

프로그래머스

코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.

programmers.co.kr