프로그래머스 - Python
문제집 링크 : http://aladin.kr/p/szPra
프로그래머스 URL :
■ 작성 코드
def solution(s):
answer = [-1] * len(s)
order = {}
for idx, word in enumerate(s):
if word in order:
answer[idx] = idx - order[word]
order[word] = idx
return answer
반응형
'Programming Test > 문제풀이' 카테고리의 다른 글
[프로그래머스] 27. 완주하지 못한 선수 - Python (0) | 2025.02.01 |
---|---|
[프로그래머스] 26. 숫자 문자열과 영단어 - Python (0) | 2025.01.31 |
[프로그래머스] 24. 성격 유형 검사하기 - Python (0) | 2025.01.28 |
[프로그래머스] 23. 로그인 성공? - Python (0) | 2025.01.28 |
[프로그래머스] 22. 바탕화면 정리 - Python (0) | 2025.01.27 |