Algorithm/String
[백준] 9012번 괄호
등촌동 꼬북이
2020. 11. 25. 02:02
어이 없게... 개행문자 처리를 안해줘서 오래 걸렸다..
뭔가 어려운 문제가 아닌데 라는 생각을 하다가...
디버거로 보니까... 개행문자가 껴있...
import sys
def correctCheck(str):
tempList = []
for i in range(len(str)):
if str[i] == "(":
tempList.append("(")
else:
if len(tempList) > 0:
if tempList.pop() != "(":
return "NO"
else:
return "NO"
if len(tempList) > 0:
return "NO"
return "YES"
N = int(sys.stdin.readline())
for i in range(N):
print(correctCheck(sys.stdin.readline().strip()))