def solution(s):
stack = []
for c in s:
if c == '(':
stack.append(c)
else:
if stack and stack.pop() == '(':
continue
else:
return False
return len(stack) == 0
다른 풀이
def is_pair(s):
x = 0
for w in s:
if x < 0:
break
x = x+1 if w=="(" else x-1 if w==")" else x
return x==0