-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1a7ea59
commit 8f76ede
Showing
1 changed file
with
18 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from collections import Counter | ||
def solution(k, tangerine): | ||
answer = 0 | ||
tangerine = Counter(tangerine) # 갯수 세기 | ||
|
||
tangerine_key = tangerine.keys() | ||
# 갯수에 따라 내림차순으로 정렬 | ||
tangerine_key = sorted(tangerine_key, key= lambda x: tangerine[x], reverse=True) | ||
|
||
for key in tangerine_key: | ||
if tangerine[key] < k: # 귤을 모드 넣을 수 있는 경우 | ||
k -= tangerine[key] | ||
answer += 1 | ||
else: # 일부만 넣을 수 있는 경우 | ||
answer += 1 | ||
break | ||
|
||
return answer |