<doocs>0032.Longest Valid Parentheses_1.py
def longestValidParentheses( s):
    Longest = temp = 0
    stack = []
    
    for i in s:
        if i == '(':
            stack.append(i)
        elif len(stack) != 0 and stack[-1] == '(':
            stack.pop()
            temp += 2
        else:
            stack = []
            if temp > Longest:
                Longest = temp
            temp = 0
    if temp > Longest:
        Longest = temp
    return Longest
def sample_funcname ( var_0 ) :
    var_3 = var_1 = 0
    var_4 = [ ]
    for var_5 in var_0 :
        if var_5 == '(' :
            var_4.append ( var_5 )
        elif len ( var_4 ) != 0 and var_4 [ - 1 ] == '(' :
            var_4.pop ( )
            var_1 += 2
        else :
            var_4 = [ ]
            if var_1 > var_3 :
                var_3 = var_1
            var_1 = 0
    if var_1 > var_3 :
        var_3 = var_1
    return var_3
