-Code
count = {}
s = input()
for el in s:
if el in count:
count[el] += 1
else:
count[el] = 1
odd = 0
for val in count.values():
if val % 2 == 1:
odd += 1
if odd > 1:
print("I'm Sorry Hansoo")
exit()
half = ""
middle = ""
for key, val in sorted(count.items()):
if val % 2 == 1:
middle = key
if val != 1 and val % 2 == 1:
val = val - 1
half += key * (val // 2)
print(half + middle + half[::-1])
'Beakjoon&프로그래머스 > 파이썬' 카테고리의 다른 글
[백준/파이썬] 9622번 Cabin Baggage (0) | 2025.02.05 |
---|---|
[백준/파이썬] 9945번 Centroid of Point Masses (0) | 2025.02.04 |
[백준/파이썬] 6162번 Superlatives (0) | 2025.02.02 |
[백준/파이썬] 33191번 Yalda (1) | 2025.02.01 |
[백준/파이썬] 33179번 Hezardastan’s Annual Report (0) | 2025.01.31 |