<qiyuangong>042_Trapping_Rain_Water_2.py
def trap( height):
    ls = len(height)
    if ls == 0:
        return 0
    height.append(0)
    height.insert(0, 0)
    left = [0] * ls
    right = [0] * ls
    cur_left, cur_right = 0, 0
    for i in range(1, ls + 1):
        cur_left = max(cur_left, height[i - 1])
        
        left[i - 1] = cur_left
    for i in reversed(range(ls)):
        cur_right = max(cur_right, height[i + 1])
        
        right[i] = cur_right
    res = 0
    for i in range(ls):
        curr = min(left[i], right[i])
        if curr > height[i]:
            res += curr - height[i]
    return res
def sample_funcname ( var_0 ) :
    var_2 = len ( var_0 )
    if var_2 == 0 :
        return 0
    var_0.append ( 0 )
    var_0.insert ( 0 , 0 )
    var_6 = [ 0 ] * var_2
    var_7 = [ 0 ] * var_2
    var_8 , var_9 = 0 , 0
    for var_12 in range ( 1 , var_2 + 1 ) :
        var_8 = max ( var_8 , var_0 [ var_12 - 1 ] )
        var_6 [ var_12 - 1 ] = var_8
    for var_12 in reversed ( range ( var_2 ) ) :
        var_9 = max ( var_9 , var_0 [ var_12 + 1 ] )
        var_7 [ var_12 ] = var_9
    var_15 = 0
    for var_12 in range ( var_2 ) :
        var_17 = min ( var_6 [ var_12 ] , var_7 [ var_12 ] )
        if var_17 > var_0 [ var_12 ] :
            var_15 += var_17 - var_0 [ var_12 ]
    return var_15
