input example 1:
'aab'
output example 1:
'a'
input example 2:
'dfdefdgf'
output example 2:
'df'
저를 포함해 많은 분들은 아래처럼 반복문을 이용해 작성할 것이라고 예상돼요!
my_str = input().strip()
answer = ''
tmp = []
for i in range(0, len(my_str)):
tmp.append(my_str.count('%s' % my_str[i]))
max = max(tmp)
tmp = list(i for i, j in enumerate(tmp) if j == max)
for i in tmp:
if my_str[i] not in answer:
answer += my_str[i]
print(''.join(sorted(answer)))
알아보았더니! 파이썬에선 collections.Counter 클래스를 이용하면 아주 간단하게, 간략하게 코드를 작성할 수 있답니다.
import collections
my_str = input().strip()
answer = collections.Counter(my_str)
print(sorted(answer))