1157-b1 성공
This commit is contained in:
29
workbook_8708/1157-b1.py
Normal file
29
workbook_8708/1157-b1.py
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
# 단어 공부
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from collections import Counter
|
||||||
|
|
||||||
|
input = sys.stdin.readline
|
||||||
|
|
||||||
|
def solution():
|
||||||
|
word = input().rstrip().upper()
|
||||||
|
char_list = Counter(word)
|
||||||
|
ordered_c = char_list.most_common(2)
|
||||||
|
if len(ordered_c) == 1 or ordered_c[0][1] != ordered_c[1][1]:
|
||||||
|
print(ordered_c[0][0])
|
||||||
|
else:
|
||||||
|
print("?")
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
solution()
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
걸린 시간: 15분
|
||||||
|
|
||||||
|
해설: 문자 전체를 대문자로 바꾼 다음 Counter를 활용하여 각 문자당 개수를 센다.
|
||||||
|
most_common(2)으로 가장 많이 나온 문자 2개를 가져오는데, 이 때, 1개라면 그냥 출력하면 되고
|
||||||
|
2개라면 두 문자가 나온 빈도수가 다르다면 공동 1등이 없다는 뜻이므로 정렬되어 있기 때문에
|
||||||
|
첫 번째 문자를 가져온다.
|
||||||
|
"""
|
||||||
Reference in New Issue
Block a user