코테 대비 python/백준
10809 공식을 유도하지말고 외우자
ylab
2023. 1. 31. 11:00
https://www.acmicpc.net/problem/10809
10809번: 알파벳 찾기
각각의 알파벳에 대해서, a가 처음 등장하는 위치, b가 처음 등장하는 위치, ... z가 처음 등장하는 위치를 공백으로 구분해서 출력한다. 만약, 어떤 알파벳이 단어에 포함되어 있지 않다면 -1을 출
www.acmicpc.net
s= input()
test=[]
test_s=[]
cnt=0
for i in s:
if i in test_s:
cnt+=1
else:
test_s.append(i)
test.append([i,cnt])
cnt+=1
alpha=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
for j in alpha:
flag=0
for k in test:
if j == k[0]:
print(k[1],end=" ")
flag=1
if flag ==0:
print(-1,end=" ")
https://gururuglasses.tistory.com/88 분의 풀이
암기하자
S = input()
abc ='abcdefghijklmnopqrstuvwxyz'
for i in abc:
if i in S:
print(S.index(i), end= ' ')
else:
print( -1, end =' ')