본문 바로가기

Coding Test/Programmers

[프로그래머스/파이썬] 올바른 괄호

728x90

 

 

나의 풀이

def solution(s):
    stack = []

    for l in s:
        if l =='(':
            stack.append(l)
        elif stack:
            stack.pop()
        else:
            return False

    if stack:
        return False
    else:
        return True

 

 

 

반응형