Algorithms
[λ°±μ€] 1157λ²: λ¨μ΄ κ³΅λΆ python
thals0
2022. 7. 15. 17:39
728x90
https://www.acmicpc.net/problem/1157
1157λ²: λ¨μ΄ 곡λΆ
μνλ²³ λμλ¬Έμλ‘ λ λ¨μ΄κ° μ£Όμ΄μ§λ©΄, μ΄ λ¨μ΄μμ κ°μ₯ λ§μ΄ μ¬μ©λ μνλ²³μ΄ λ¬΄μμΈμ§ μμλ΄λ νλ‘κ·Έλ¨μ μμ±νμμ€. λ¨, λλ¬Έμμ μλ¬Έμλ₯Ό ꡬλΆνμ§ μλλ€.
www.acmicpc.net
μ λ΅ μ½λ:
word = input().upper()
uni = list(set(word))
cnt=[]
for i in uni:
count = word.count(i)
cnt.append(count)
if cnt.count(max(cnt))>1:
print("?")
else:
max_index=cnt.index(max(cnt))
print(uni[max_index])
728x90