Skip to content

Commit

Permalink
84 완
Browse files Browse the repository at this point in the history
  • Loading branch information
seongwon02 committed Aug 17, 2024
1 parent 1a7ea59 commit 8f76ede
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions SWKIM/81to90/84.py
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

0 comments on commit 8f76ede

Please sign in to comment.