(s)
return True
有效的括号序列
有效的括号序列
有效的括号序列
def valid_parentheses(s):
    """有效的括号序列"""
    stack = []
    for i in s:
        if i == '(':
            stack.append(i)
        elif i == ')' and len(stack) == 0:
            return False
        else:
            stack.pop()
    return True
def valid_parentheses ( s ) : stack = [ ] for i in s : if i == '(' : stack . append ( i ) elif i == ')' and len ( stack ) == 0 : return False else : stack . pop ( ) return True