def solution(k, tangerine):
tan_set = set(tangerine)
# ๊ทค ๋ฌด๊ฒ์ ์ข
๋ฅ ๊ตฌํ๋ ค๊ณ ์ค๋ณต ์ ๊ฑฐ
tan_dict = {}
count_k = i = answer = 0
# ๊ทค์ ๋ฌด๊ฒ๋ฅผ key, ๊ทธ ๋ฌด๊ฒ์ ๊ฐฏ์๋ฅผ value๋ก ๊ฐ๋ dictionary ์์ฑ
for t in tangerine:
if t in tan_dict:
tan_dict[t] += 1
else:
tan_dict[t] = 1
tan_dict = sorted(tan_dict.items(), key = lambda item: item[1], reverse = True)
# ๊ทค์ ๊ฐฏ์ ๊ธฐ์ค์ผ๋ก ๋ด๋ฆผ์ฐจ์ sort ์ํด
while True:
count_k += tan_dict[i][1]
answer += 1
if count_k >= k :
# k์ ๊ฐฏ์๋ฅผ ์ ๋ ฌ ํ์ผ๋๊น ๋ํด์ ๊ตฌํ๋ฉด ๋๋ค.
break
else :
i +=1
return answer