[알고리즘/백준] 10808: 알파벳 찾기(python)

유현민·2022년 4월 6일
0

알고리즘

목록 보기
102/253

이것도 여러가지 방법이 있지만... 자료구조를 이용해서 풀었다.

from collections import deque

a = deque(list(input()))
ans = [-1] * 26
i = 0
while a:
    k = a.popleft()
    if ans[ord(k) - ord('a')] == -1:
        ans[ord(k) - ord('a')] = i
    i += 1
print(*ans)
profile
smilegate megaport infra

0개의 댓글