[프로그래머스] 올바른 괄호

O2o2✨·2020년 11월 29일
0

알고리즘

목록 보기
7/43

링크 : 프로그래머스 - 연습문제 > 올바른 괄호

풀이 (python)

def solution(s):
    stack = []
    
    for ch in s:
        if ch == '(':
            stack.append(ch)
        elif stack:
            stack.pop()
        else:
            return False
    
    return False if stack else True
profile
프론트엔드 & 퍼블리셔

0개의 댓글