728x90
제목
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
정답
import java.util.*;
class Solution {
public int[] solution(int[] array, int[][] commands) {
int[] answer = new int[commands.length];
ArrayList<Integer> nums = new ArrayList<>();
for (int arr : array) {
nums.add(arr);
}
for (int i = 0; i < commands.length; i++) {
List<Integer> sub = nums.subList(commands[i][0]-1, commands[i][1]);
List<Integer> subNum = new ArrayList<>(sub);
Collections.sort(subNum);
answer[i] = subNum.get(commands[i][2]-1);
}
return answer;
}
}
728x90
'프로그래머스 코딩테스트 > JAVA' 카테고리의 다른 글
[프로그래머스] 명예의 전당 (1) JAVA (0) | 2024.08.05 |
---|---|
[프로그래머스] 2016년 JAVA (0) | 2024.08.05 |
[프로그래머스] 두 개 뽑아서 더하기 JAVA (0) | 2024.08.02 |
[프로그래머스] 문자열 내 마음대로 정렬하기 JAVA (0) | 2024.08.01 |
[프로그래머스] 숫자 문자열과 영단어 JAVA (0) | 2024.07.30 |