Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- math
- oracle
- 건강
- MySQL
- db
- priorityqueue
- 백준
- 시뮬레이션
- BOJ
- dfs
- 문자열
- greedy
- COS PRO
- SQL
- 코테
- 알고리즘
- 투포인터
- 프로그래머스
- DP
- 코딩테스트
- SWEA
- 자바
- 문제풀이
- Java
- 문제해결
- 이분탐색
- BFS
- binary search
- 운동기록
- 러닝일지
Archives
- Today
- Total
슈콩
[프로그래머스] Lv.1 K번째수 본문


[문제]
https://school.programmers.co.kr/learn/courses/30/lessons/42748
프로그래머스
SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프
programmers.co.kr
[소스 코드]
import java.util.*;
class Solution {
public int[] solution(int[] array, int[][] commands) {
int n = commands.length;
int[] answer = new int[n];
for(int i=0;i<n;i++){
List<Integer> list = new ArrayList<>();
int start = commands[i][0] - 1;
int end = commands[i][1] - 1;
for(int j=start;j<=end;j++){
list.add(array[j]);
}
Collections.sort(list);
answer[i] = list.get(commands[i][2]-1);
}
return answer;
}
}'Algorithms > Programmers' 카테고리의 다른 글
| [프로그래머스] Lv.2 소수 찾기 (0) | 2025.10.09 |
|---|---|
| [프로그래머스] Lv.2 가장 큰 수 (0) | 2025.10.08 |
| [프로그래머스] Lv.2 게임 맵 최단 거리 (0) | 2025.10.08 |
| [프로그래머스] Lv.1 비밀지도 (0) | 2025.10.07 |
| [프로그래머스] Lv.1 크레인 인형뽑기 게임 (0) | 2025.10.07 |