어이 없게... 개행문자 처리를 안해줘서 오래 걸렸다..
뭔가 어려운 문제가 아닌데 라는 생각을 하다가...
디버거로 보니까... 개행문자가 껴있...
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()))
'Algorithm > String' 카테고리의 다른 글
[백준] 3059번 등장하지 않는 문자의 합 (0) | 2021.02.08 |
---|---|
[백준] 9935번 문자열 폭발 (0) | 2021.02.08 |
[백준] 1764번 듣보잡 (0) | 2021.02.08 |
[백준] 1213번 팰린드롬 만들기 (0) | 2021.01.08 |
[백준] 2941번 크로아티아 알파벳 (0) | 2020.11.25 |
댓글