알파벳 찾기


Define input, output

  • Input: 소문자로 이루어진 단어 S
  • Output: 각 알파벳이 처음 나온 위치

source code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
import sys


S = sys.stdin.readline().strip()
result = [-1] * (ord("z") - ord("a") + 1)

for i, string in enumerate(S):
    if result[ord(string) - ord("a")] == -1:
        result[ord(string) - ord("a")] = i

print(*result)
Built with Hugo
Theme Stack designed by Jimmy