[Programmers] 가장 가까운 같은 글자
Python
def solution(s):
answer = []
s_lst = []
for idx, val in enumerate(s):
temp = 0
if val in s_lst:
for j in range(idx):
if val == s[j]:
temp = j
answer.append(idx - temp)
else:
s_lst.append(val)
answer.append(-1)
return answer
댓글남기기