일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- PathVariable
- 빌드
- 프론트엔드
- 도커
- Java
- RequestParam
- fetch
- aop
- Vue.js
- transaction
- axios
- gradle
- 자바 버전
- 개발자
- Spring AOP
- java version
- maven
- GIT
- git push
- github
- docker
- VUE
- RequestBody
- vue life cycle
- 백엔드
- 트랜잭션
- 비동기통신
Archives
- Today
- Total
미소의 세상
[알고리즘] 정렬-K번째수 본문
https://programmers.co.kr/learn/courses/30/lessons/42748
돌려가면서 작성
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 |
Comments