class Solution(object):
def isValid(self, s):
"""
:type s: str
:rtype: bool
"""
if len(s)==0:
return True
stack=[]
string={")":"(","}":"{","]":"["}
temp=["(","{","["]
for i in s:
if i in temp:
stack.append(i)
elif stack and stack[-1]==string[i]:
stack.pop()
else:
return False
if len(stack)==0:
return True
else:
return False