Case = int(input())
for _ in range(Case):
string = list(input())
close_cnt = 0
while(len(string) != 0):
if(close_cnt < 0):
break
res = string.pop()
if(res == '('):
close_cnt -= 1
elif(res == ')'):
close_cnt += 1
if(close_cnt == 0):
print('YES')
else:
print('NO')
'# 코딩 문제 관련 > 파이썬' 카테고리의 다른 글
백준 10845번(python) (0) | 2019.06.17 |
---|---|
백준 2504번(python) (0) | 2019.06.03 |
백준 1874번(python) (0) | 2019.06.02 |
백준 10828번(python) (0) | 2019.06.02 |
백준 9020번(python) (0) | 2019.05.31 |