nums는 숫자로 이루어진 배열입니다.
가장 자주 등장한 숫자를 k 개수만큼 return 해주세요.
nums = [1,1,1,2,2,3],
k = 2
return [1,2]
nums = [1]
k = 1
return [1]
def top_k(nums, k):
# 여기에 코드를 입력해주세요
diction = {}
lists = []
final = []
current = 0
for i in nums:
current = nums.count(i)
diction[current] = i
lists = list(diction.keys())
lists.sort(reverse=True)
for j in range(k):
final.append(diction[lists[j]])
return final