[Level 2] 올바른 괄호

나며기·2021년 9월 22일
0

programmers

목록 보기
58/111
post-thumbnail
def solution(s):
    stack = []
    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 True
    else:
        return False
profile
PLUS ULTRA

0개의 댓글