def solution(s):
answer = False
stack = []
if s.count('(') == s.count(')'):
for i in s:
if i == '(':
stack.append(i)
else:
if len(stack) == 0:
return False
else:
stack.pop()
if len(stack) == 0:
answer = True
return answer
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