티스토리 뷰
[문제]

[해답]
import java.util.Arrays;
class Solution {
public int[] solution(int[] array, int[][] commands) {
int[] answer = new int[commands.length];
for(int i = 0; i < commands.length; i++) {
int start = commands[i][0] - 1;
int end = commands[i][1] - 1;
int k = commands[i][2];
int[] tmp = new int[end - start + 1];
int index = 0;
for(int j = start; j <= end; j++) {
tmp[index] = array[j];
index++;
}
Arrays.sort(tmp);
answer[i] = tmp[k - 1];
}
return answer;
}
}

'흥미 > 코딩테스트' 카테고리의 다른 글
| #28😊 같은 숫자는 싫어 with Stack (0) | 2024.02.26 |
|---|---|
| #27😊 두 개 뽑아서 더하기 (0) | 2023.08.10 |
| #25😊 완주하지 못한 선수 (0) | 2023.07.15 |
| #24😂 달리기 경주 / indexOf는 시간복잡도가 많이 든다! (0) | 2023.04.16 |
| #23😊 추억 점수 (0) | 2023.04.04 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- MongoDB
- db
- 빅데이터
- 코딩테스트
- OS
- 프로그래머스
- Phaser3
- 코테
- 메모리
- 운영체제
- 알고리즘
- nosql
- Advanced Stream
- Spring Boot
- jpa
- node.js
- SpringBoot
- java
- 자료구조
- Stream
- spring
- DART
- Java8
- 프로세스
- git
- MySQL
- SQL
- 빅데이터 분석기사
- Phaser
- API
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| 26 | 27 | 28 | 29 | 30 | 31 |
글 보관함
