L2 : 짝지어 제거하기 Python

jhyunn·2023년 1월 25일
0

Programmers

목록 보기
67/69

L2 : 짝지어 제거하기 Python

https://school.programmers.co.kr/learn/courses/30/lessons/12973

def solution(s):
    temp = [s[0]]
    for i in range(1, len(s)):
        temp.append(s[i])
        if temp[-2:] == [temp[-1]]*2:
            temp.pop()
            temp.pop()
    if len(temp) > 0:
        return 0
    return 1
profile
https://github.com/Sungjeonghyun

0개의 댓글