반응형 백준90121 #9 [파이썬] 백준 9012번 문제: 괄호 www.acmicpc.net/problem/9012 n = int(input()) for i in range(n): a = list(input()) tmp = [] cnt = 0 for j in a: if j == "(": tmp.append(j) elif j == ")": if not tmp: print("NO") cnt = 1 break else: tmp.pop() if not tmp and cnt == 0: print("YES") elif len(tmp) != 0 and cnt == 0: print("NO") 1. Solution 리스트 a내의 "("와 ")"의 개수가 다른 경우 또는 a의 첫 원소가 ")"인 경우는 NO이다. 먼저 "("와 ")"의 개수를 체크하기 위해, tmp라는 리스트를 만든 .. 2021. 4. 7. 이전 1 다음 728x90 반응형