[アルゴリズム/標準]10808:アルファベット検索(python)



これもいろいろな方法があります.資料構造を用いて解答を行った.
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)