Algorithm/BOJ 기초
[백준] 괄호 9012 Python
hackyu
2019. 10. 18. 04:20
|
1
2
3
4
5
6
7
8
9
|
N = int(input())
for i in range(N):
temp = input()
while "()" in temp:
temp = temp.replace("()", "")
if len(temp) > 0:
print("NO")
else:
print("YES")
|
|
Stack으로 풀 수 있지만 replace를 이용하여 제거 해나가는 식으로 가능함.