用字典简化代码量 class Solution: def isValid(self , s ): k = {'}':'{', ')':'(', ']':'[' } stack = [] for a in s: if a in k.values(): stack.append(a) elif not stack or k[a] != stack.pop(): return False return len(stac...