파비의 매일매일 공부기록

[BOJ] 1157 본문

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))
반응형

'Problem Solving > BOJ' 카테고리의 다른 글

[BOJ] 1173  (0) 2022.01.24
[BOJ] 1159  (0) 2022.01.23
[BOJ] 1152  (0) 2022.01.21
[BOJ] 1145  (0) 2022.01.20
[BOJ] 1110  (0) 2022.01.19
Comments