Files
baekjoon-study/workbook_8708/1157-b1.py
2026-01-19 13:50:32 +09:00

29 lines
784 B
Python

# 단어 공부
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등이 없다는 뜻이므로 정렬되어 있기 때문에
첫 번째 문자를 가져온다.
"""