[20251021] PGM / LV2 / 귤 고르기 / 강신지 #1185
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/138476
🧭 풀이 시간
15분
👀 체감 난이도
✏️ 문제 설명
귤 여러 개 중 k개를 한 박스에 담을 것. 각 귤의 크기(정수)를 담은 배열이 주어지고, 박스에 담는 귤의 크기 종류는 최소여야 함. 몇 가지 크기의 귤이 담길 것인가?
🔍 풀이 방법
맵에 귤 크기와 개수를 담아두고 개수 기준 내림차순 정렬해서 리스트에 담음. 그걸 하나씩 sum에 더하면서 종류 수도 더함. k개 이상이 되면 그때의 크기 종류 수 리턴.
⏳ 회고