class Solution:
def isValid(self, s):
"""
:type s: str
:rtype: bool
"""
dict={"()","[]","{}"}
arr=[]
for i in range(len(s)):
if len(arr)!=0 and (arr[-1]+s[i]) in dict:
arr.pop()
else:
arr.append(s[i])
return len(arr)==0