티스토리 뷰
import java.util.ArrayList;
import java.util.Arrays;
class Solution {
public int[] solution(int[] array, int[][] commands) {
int[] answer = new int[commands.length];
ArrayList<Integer> list = new ArrayList<Integer>();
for (int c = 0; c < commands.length; c++) {
int i = commands[c][0];
int j = commands[c][1];
int k = commands[c][2];
int[] arr = Arrays.copyOfRange(array, i - 1, j);
Arrays.sort(arr);
answer[c] = arr[k-1];
}
return answer;
}
}
- Arrays.copyOfRange가 생각나서 쉽게 풀 수 있었다
- Arrays.copyOfRange 할때는 (원본, 시작, 끝) 인데 주의할 점은 끝바로 앞까지만 copy 된다.
'PS > programmers' 카테고리의 다른 글
Level1) 같은 숫자는 싫어 (0) | 2020.09.08 |
---|---|
Level1) 가운데 글자 가져오기 (0) | 2020.09.08 |
Level1) 2016년 (0) | 2020.09.08 |
Level1) 모의고사 (0) | 2020.09.08 |
Level1) 체육복 (0) | 2020.09.08 |
링크
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- Spring Security
- dreamcoding
- HTTP 완벽 가이드
- http
- 패스트캠퍼스 컴퓨터공학 완주반
- 킹수빈닷컴
- js api
- js array
- 백준
- JS 딥다이브
- js promise
- 이펙티브자바 스터디
- ㅇㄷㅇㅈ
- 백기선 스터디
- GCP
- 프로그래머스
- 모던자바스크립트
- BOJ
- 이펙티브자바 아이템59
- REST API
- HTTP 완벽가이드
- 이펙티브자바
- 프로그래머스 SQL
- 드림코딩
- JPA 연관관계 매핑
- 이펙티브자바 아이템60
- 가상 면접 사례로 배우는 대규모 시스템 설계 기초
- 김영한 JPA
- java
- 김영한 http
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함