본문 바로가기
코딩테스트/Python

프로그래머스 스쿨 - 올바른 괄호(Python)(복습)

by 보안매크로 2023. 10. 21.
728x90
def solution(s):
    stack = []

    for i in s:
        if i == '(':
            stack.append(i)
        elif i == ')':
            if stack:
                    stack.pop()
                    #print(stack.pop())
            else:
                return False  
           
    return len(stack) == 0
728x90