Multibrackets.py
def solution(S):
lenS=len(S)
hashmap={"}":"{","]":"[",")":"("}
stack=[]
for i in range(lenS):
if S[i]=="{" or S[i]=="[" or S[i]=="(":
stack.append(S[i])
else:
if len(stack)!=0 and stack[-1]==hashmap[S[i]]:
stack.pop()
else: # len(stack)==0 이거나 짝이 안맞게 ) } ] 들어올경우
return 0
if len(stack)!=0: #stack 이 { [ ( 채워진경우 (짝이 안맞을 경우)
return 0
else:
return 1