[20251118] PGM / Lv2 / [3차] 파일명 정렬 / 이강현 #1442
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🧷 문제 링크
https://school.programmers.co.kr/learn/courses/30/lessons/17686?language=java
🧭 풀이 시간
30분
👀 체감 난이도
✏️ 문제 설명
파일들이 존재함.
파일들은 head,number,tail로 이루어짐.
head는 문자열, number는 숫자, tail은 둘다 섞임.
head와 number를 기준으로 정렬하고 둘 다 같다면 순서를 유지해야함.
🔍 풀이 방법
정렬
File이라는 class를 만들고 원래 파일 이름, head, number, 기존 인덱스를 저장함.
compareTo를 오버라이드해서 정렬 조건을 다르게함.
⏳ 회고
원래는 stream을 알고리즘에서 느려서 안쓴다고 하는데,
문제 자체가 구현이고 시간에 대한 평가가 없다면 스트림을 공부해서 써보는 것도 좋을 것 같다.