📋오늘 푼 코딩테스트
더보기
https://school.programmers.co.kr/learn/courses/30/lessons/42748
프로그래머스
SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프
programmers.co.kr
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
class Solution {
public int[] solution(int[] array, int[][] commands) {
int[] answer = new int[commands.length];
for (int i = 0; i < commands.length; i++) {
List<Integer> lists = new ArrayList<>();
// commands[i][1]까지 포함해야 하므로 '<='가 아니라 '<'로 수정
for (int j = commands[i][0] - 1; j < commands[i][1]; j++) {
lists.add(array[j]);
}
Collections.sort(lists);
answer[i] = lists.get(commands[i][2] - 1);
}
return answer;
}
}
📖 오늘 작성한 글
✒️ 회고
- 코딩테스트 답이 맞더라도 1점이라는건 좋은 코드는 아니라는 것이다.
- 이제 JDBC 말고 실무에서도 사용하는 JPA 를 공부해야겠다.
'TIL' 카테고리의 다른 글
[TIL]2025-04-01 (0) | 2025.04.01 |
---|---|
[TIL]2025-03-31 (1) | 2025.03.31 |
[TIL]2025-03-26 (0) | 2025.03.26 |
[TIL]2025-03-25 (0) | 2025.03.25 |
[TIL]2025-03-24 (0) | 2025.03.24 |