본문 바로가기

알고리즘/백준 (Pyhthon)

[알고리즘] 백준 1302 베스트셀러

 

n = int(input())

book_list = {}

for _ in range(n):
    book = input()
    if book in book_list:
        book_list[book] += 1
    else:
        book_list[book] = 1

target = max(book_list.values())
array = []

for k, v in book_list.items():
    if v == target:
        array.append(k)
        
book_max = []
book_max = sorted(array)
print(book_max[0])