- 딕셔너리를 이용해서 해당
key
값을 문자로 처리한 다음value
값만큼 곱해준다.
import sys
input = sys.stdin.readline
dict = {}
N, C = map(int, input().strip().split())
message = list(map(int, input().strip().split()))
for i in message:
if i not in dict:
dict[i] = 1
else:
dict[i] += 1
new_dict = sorted(dict.items(), key = lambda x : (-x[1]))
for i in range(len(new_dict)):
print((str(new_dict[i][0]) + " ") * new_dict[i][1], end = "")