๋ฐ์ํ
Solution
1) ๋์ ๋๋ฆฌ ์ฌ์ฉ
2) ํ์ค ์ ์ถ๋ ฅ
๐ ์ต์ข ๋ง์ ๋ต
#1302 ๋ฒ ์คํธ ์
๋ฌ 2์ด
# sys.stdin.readlines()
import sys
N = int(sys.stdin.readline()) # 1,000๋ณด๋ค ์๊ฑฐ๋ ๊ฐ์ ์์ฐ์
books = {}
for i in range(N):
book_name = sys.stdin.readline()
if(book_name in books):
books[book_name]+=1
else:
books[book_name] =1
max_count = max(list(books.values()))
best_seller=[]
for book,num in books.items():
if num == max_count:
best_seller.append(book)
print(sorted(best_seller)[0])
์ ํ๋ ธ๋?
1. sys.stdin.readline() ์ด๋ถ๋ถ์ readlines()๋ผ๊ณ ๋ถ์ด๊ณ ์์๋ค..
๋ฐ์ํ
'CodingTest' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Python]๋ฐฑ์ค 9012::๊ดํธ ๋ฌธ์ ํ์ด (0) | 2021.05.04 |
---|---|
[Python]๋ฐฑ์ค 7785::ํ์ฌ์ ์๋ ์ฌ๋ (0) | 2021.05.04 |
[Python] ๋ฌธ์ ํ ๋ ์๊ณ ๋ฆฌ์ฆ์ ์ฃผ๋ก ์ฌ์ฉํ๋ ์๋ฃ๊ตฌ์กฐ ํ์ฉ๋ฒ์ ์์๋ณด์! (0) | 2021.05.04 |
[Python]๋ฐฑ์ค 1110๋ฒ::๋ํ๊ธฐ ์ฌ์ดํด (0) | 2021.04.29 |
[Python]๋ฐฑ์ค 3085๋ฒ::์ฌํ ๊ฒ์ (0) | 2021.04.29 |
๋๊ธ