class Solution(object):
def isValid(self, s):
"""
:type s: str
:rtype: bool
"""
hm = {'{':'}','(':')','[':']'}
keys = hm.keys()
stack = []
for i in s:
if i in keys:
stack.append(i)
else:
if not stack or hm[stack[-1]] != i:
return False
stack.pop()
return len(stack) == 0