반응형
문제
https://school.programmers.co.kr/learn/courses/30/lessons/140108
프로그래머스
SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프
programmers.co.kr
해설
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)
반응형