
💻Q
코딩테스트 연습 - K번째수
[1, 5, 2, 6, 3, 7, 4] [[2, 5, 3], [4, 4, 1], [1, 7, 3]] [5, 6, 3]
programmers.co.kr
💡A
import java.util.Arrays; class Solution { public int[] solution(int[] array, int[][] commands) { int[] answer = new int[commands.length]; for(int i=0; i<answer.length; i++) { int[] temp = new int[commands[i][1]-(commands[i][0]-1)]; for(int j=0; j<temp.length; j++) { temp[j] = array[j+(commands[i][0]-1)]; } Arrays.sort(temp); answer[i] = temp[commands[i][2]-1]; } return answer; } }
'Algorithm > Programmers' 카테고리의 다른 글
| 프로그래머스 H-Index (0) | 2021.11.02 |
|---|---|
| 프로그래머스 네트워크 (0) | 2021.11.01 |
| 프로그래머스 섬 연결하기 (0) | 2021.10.27 |
| 프로그래머스 조이스틱 (0) | 2021.10.22 |
| [10주차] 프로그래머스 이중우선순위큐 (0) | 2021.10.02 |