class Solution(object):
def isValid(self, s):
"""
:type s: str
:rtype: bool
"""
left=[u'[',u'{',u'(']
right=[u']',u'}',u')']
s=list(s)
stack=[]
for i in s:
if i in left:
stack.append(i)
else:
if len(stack)<=0:
return False
else:
mid=stack.pop(-1)
if left.index(mid)==right.index(i):
continue
else:
return False
if len(stack)>0:
return False
return True