Skip to content
Discussion options

You must be logged in to vote

stack을 이용해서 하나씩 꺼내고 다음 문자랑 맞춰서 제거해보시는건 어떨까요?

def solution(s): 
    stack = []
    if len(s) == 0 : return 0
    for i in s:
        if len(stack) == 0: stack.append(i)
        elif stack[-1] == i: stack.pop()
        else: stack.append(i)
    if len(stack) == 0: return 1
    else: return 0

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by LearningnRunning
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants