<qiyuangong>946_Validate_Stack_Sequences_1.py
def validateStackSequences( pushed, popped):
    in_stack = []
    pos = 0
    while pos != len(pushed):
        curr = pushed[pos]
        while len(in_stack) > 0 and len(popped) > 0 and in_stack[-1] == popped[0]:
            in_stack.pop(-1)
            popped.pop(0)
        if len(popped) == 0:
            break
        if curr == popped[0]:
            popped.pop(0)
        else:
            in_stack.append(curr)
        pos += 1
    while len(in_stack) > 0 and len(popped) > 0 and in_stack[-1] == popped[0]:
        in_stack.pop(-1)
        popped.pop(0)
    if len(in_stack) == 0:
        return True
    return False
def sample_funcname ( var_0 , var_1 ) :
    var_2 = [ ]
    var_4 = 0
    while var_4 != len ( var_0 ) :
        var_6 = var_0 [ var_4 ]
        while len ( var_2 ) > 0 and len ( var_1 ) > 0 and var_2 [ - 1 ] == var_1 [ 0 ] :
            var_2.pop ( - 1 )
            var_1.pop ( 0 )
        if len ( var_1 ) == 0 :
            break
        if var_6 == var_1 [ 0 ] :
            var_1.pop ( 0 )
        else :
            var_2.append ( var_6 )
        var_4 += 1
    while len ( var_2 ) > 0 and len ( var_1 ) > 0 and var_2 [ - 1 ] == var_1 [ 0 ] :
        var_2.pop ( - 1 )
        var_1.pop ( 0 )
    if len ( var_2 ) == 0 :
        return True
    return False
