阅读背景:

20-ValidParentheses

来源:互联网 

标题:断定大、中、小括号是不是合法。“()”、"([)]"、"{(([])}"

def isValid(string):
    dic = {"}":"{","]":"[",")":"("}
    stack = []
    for s in string:
        if s not in dic:
            stack.append(s)
        else:
            if len(stack)>0 and dic[s]==stack[-1]:
                stack.pop()
            else:
                return False

    return True
def is



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: