← Back to List

2910번: 빈도 정렬 ↗

Solutions

Python 3
308 B | 308 chars
N,C=list(map(int,input().split()))
L = list(map(int,input().split()))
K = dict()
C = dict()
for i,j in enumerate(L):
    if j not in K:
        K[j] = i 
    if j not in C:
        C[j] = 1
    else:
        C[j]+=1

L.sort(key=lambda t : K[t])

L.sort(key=lambda t: N-C[t])

for i in L:
    print(i,end=" ")