일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- docker
- aop
- RequestParam
- 도커
- RequestBody
- 비동기통신
- Java
- vue life cycle
- PathVariable
- 백엔드
- git push
- 개발자
- java version
- 프론트엔드
- 자바 버전
- 빌드
- transaction
- VUE
- maven
- axios
- 트랜잭션
- github
- fetch
- Vue.js
- gradle
- Spring AOP
- GIT
Archives
- Today
- Total
미소의 세상
[알고리즘] 정렬-K번째수 본문
https://programmers.co.kr/learn/courses/30/lessons/42748
코딩테스트 연습 - K번째수
[1, 5, 2, 6, 3, 7, 4] [[2, 5, 3], [4, 4, 1], [1, 7, 3]] [5, 6, 3]
programmers.co.kr
돌려가면서 작성
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 k = 0;
int [] temp = new int[commands[i][1] - (commands[i][0]-1)];
for(int j = commands[i][0] -1; j <= commands[i][1] -1 ; ++j){
temp[k] = array[j];
k++;
}
Arrays.sort(temp);
answer[i] = temp[commands[i][2] -1];
}
return answer;
}
}
'알고리즘 > 알고리즘 풀이' 카테고리의 다른 글
[알고리즘] 키패드 누르기 (0) | 2022.04.10 |
---|---|
[알고리즘] 완주하지 못한 선수 (0) | 2022.03.14 |
[알고리즘] 나누어 떨어지는 숫자 배열 (0) | 2022.03.10 |
[알고리즘] 타겟넘버 (0) | 2022.03.06 |
[알고리즘] 신규 아이디 추천 (0) | 2022.02.27 |