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
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