practivceAlgorithm/백준
[백준][Python] 1302 베스트셀러
findTheValue
2021. 10. 3. 15:27
책 판매량 저장하고 내림차순, 사전순 정렬
import sys
input = sys.stdin.readline
from collections import defaultdict
N = int(input())
sell = defaultdict(int)
for __ in range(N):
book = input().rstrip()
sell[book] += 1
arr_for_sort = []
for book in sell:
arr_for_sort.append((sell[book], str(book)))
arr_for_sort.sort(key=lambda x: (-x[0], x[1]))
print(arr_for_sort[0][1])