This repository was archived by the owner on Mar 18, 2024. It is now read-only.
[2023-10-04] sumin #299 #329
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.
PR Summary
풀이시간: 20분
<input>
files: 파일명(100글자 이내, 영문 대소문자, 숫자, 공백, 마침표, 빼기 부호만으로 이루어져있음), 1000개 이하의 파일
<solution>
head, number, tail을 나눠주고 정렬
<시간복잡도>
O(1000 * 100)
: files의 크기 * file의 최대 길이<회고>
head, number, tail을 일일히 나눠서 구현했는데..
다른 사람들 풀이를 보니 정규표현식으로 아주 깔끔하게 구현한 걸 확인..
[정규표현식 풀이]
정규표현식으로 구현할 때, number를 먼저 정렬하고, head를 정렬한다. 순서가 바뀌는 점 주의!
또, 파이썬 정렬에서 ['123', '0123']의 각 원소를 int로 변환해 정렬한다 했을 때, 같은 값이라면 순서도 유지된다는 걸 처음 알았음..