Problem Solving/BOJ

[BOJ] 1157

fabichoi 2022. 1. 22. 23:45

https://www.acmicpc.net/problem/1157 

풀긴 풀었는데.. 어거지로 푼 듯한 느낌;
그냥 문제 그대로를 소스 코드로 옮기면 됨

# BOJ 1157
str = input().upper()
ar = [0 for _ in range(26)]
for s in str:
    ar[ord(s) - ord('A')] += 1
max_index = 0
max_count = 0
for i in range(26):
    if ar[max_index] < ar[i]:
        max_index = i
        max_count = ar[i]
if ar.count(ar[max_index]) > 1:
    print('?')
else:
    print(chr(ord('A') + max_index))
반응형