Scroll indicator done
728x90

https://www.acmicpc.net/problem/9012


n = int(input())
for i in range(n):
    sentence = list(input())
    
    cnt = 0
    for s in sentence:
        if s == '(':
            cnt += 1
        elif s == ')':
            cnt -= 1
        if cnt < 0:
            print('NO')
            break
            
    if cnt > 0:
        print('NO')
    elif cnt == 0:
        print('YES')

 

728x90

'BAEKJOON > Python' 카테고리의 다른 글

[B1920][수 찾기][python]  (0) 2021.03.18
[B10828][스택][python]  (0) 2021.03.17
[B10816][숫자 카드 2][python]  (0) 2021.03.15
[B11650][좌표 정렬하기][python]  (0) 2021.03.14
[B15489][파스칼 삼각형][python]  (0) 2021.03.14