```
class Solution(object):
def isValid(self, s):
"""
:type s: str
:rtype: bool
"""
stack = []
stack.append(s[0])
for i in range(1,len(s)):
if s[i] in ["[","(","{"]:
stack.append(s[i])
else:
if len(stack) != 0:
p = stack.pop()
else:
stack.append(s[i])
if p + s[i] not in ["()","[]","{}"]:
return False
if len(stack) == 0:
return True
else:
return False
```