python-algorithm
백준 1302 베스트셀러
무적김두칠
2021. 12. 22. 11:53
1
2
3
4
5
6
7
8
|
from collections import Counter
n=int(input())
tmp=[]
for i in range(n):
tmp.append(input())
tmp.sort()
counter_tmp=Counter(tmp)
print(counter_tmp.most_common(n=1)[0][0])
|
cs |
Line 6 처럼 정렬을 안해주면
문제에서 원하는 사전순으로 제일 앞선 값이 아닌 결과가 출력 되는 경우도 있습니다
반응형