알고리즘 | 백준 9012

이도운·2022년 1월 21일

TIL

목록 보기
60/73
post-thumbnail

풀이

circle = 1
input_value = '(())())'

for i in range(circle):
    stack = []
    isVPS = True
    
    for ch in input_value:
        if ch == '(':
            stack.append(ch)
        else:
            if stack:
                stack.pop()
            else:
                isVPS = False
                break
    
    if stack:
        isVPS = False
        
print(isVPS)

전에 풀었던 코드카타 문제가 더 어려운 것 같다.

profile
⌨️ 백엔드개발자 (컴퓨터공학과 졸업)

0개의 댓글