프로그래밍/Baekjoon
(파이썬) 백준 알고리즘 10809번 알파벳 찾기
J_Remind
2019. 1. 26. 17:03
문제
풀이 (Python)
1 2 3 4 5 6 7 8 9 10 11 | S = input() check = [-1]*26 for i in range(len(S)): if check[ord(S[i])-97] != -1: continue else: check[ord(S[i])-97] = i for i in range(26): print(check[i], end=' ') | cs |
문자를 아스키코드로 변환하여 97을 뺀 인덱스에 문자열 위치를 입력해준다.
ex a=97 이므로 97-97 = 0 이여서 check[0]에 문자열의 위치 i를 넣어준다.