class Solution: def isValid(self, s: str) -> bool: if s == "": returntrue if len(s) % 2 == 1: return False a = ["?"] dic = {")": "(", "]": "[", "}": "{", "?": "?"} for i in s: if i == "(" or i == "[" or i == "{": a.append(i) elif a.pop() != dic[i]: return False if len(a) != 1: return False return True