数据结构之栈实现检查左右括号是否匹配

def isValid(self,s):
    stack = []
    paren_map = {')': '(', ']': '[', '}': '{'}
    for c in s:
        if c not in paren_map:
            stack.append(c)
        elif not stack or paren_map[c] != stack.pop():
            return False
     return not stack
原文地址:https://www.cnblogs.com/songxiaohua/p/9826991.html