class Solution:
def isValid(self , s ):
# write code here
stack = []
match = {'(':')', '[':']','{':'}'}
for i in s:
if i in match:
stack.append(i)
else:
if not stack or match[stack.pop()] != i:
return False
return not stack


京公网安备 11010502036488号