[프로그래머스] 짝지어 제거하기

rhkr9080·2022년 9월 30일
0

프로그래머스

목록 보기
5/19

문제링크 : https://school.programmers.co.kr/learn/courses/30/lessons/12973?language=python3

💻 문제 풀이

def solution(s):
    stack = []
    for i in range(len(s)):
        if not stack:
            stack.append(s[i])
        else:
            if s[i] == stack[-1]:
                stack.pop()
            else:
                stack.append(s[i])
    if stack : return 0
    else : return 1
profile
공부방

0개의 댓글