반응형
문제
https://school.programmers.co.kr/learn/courses/30/lessons/140108
해설
def solution(s):
answer = []
reset = True
for c in s:
if reset:
answer.append(c)
matched = 0
unmatched = 0
reset = False
if c == answer[-1]:
matched = matched + 1
else:
unmatched = unmatched + 1
if matched == unmatched:
reset = True
return len(answer)
반응형