<doocs>1089.Duplicate Zeros_1.py
def duplicateZeros( arr: List[int]) -> None:
    n = len(arr)
    i, k = -1, 0
    while k < n:
        i += 1
        k += 1 if arr[i] else 2
    j = n - 1
    if k == n + 1:
        arr[j] = 0
        i, j = i - 1, j - 1
    while ~j:
        if arr[i] == 0:
            arr[j] = arr[j - 1] = arr[i]
            j -= 1
        else:
            arr[j] = arr[i]
        i, j = i - 1, j - 1
def sample_funcname ( var_0 : List [ int ] ) -> None :
    var_5 = len ( var_0 )
    var_7 , var_9 = - 1 , 0
    while var_9 < var_5 :
        var_7 += 1
        var_9 += 1 if var_0 [ var_7 ] else 2
    var_11 = var_5 - 1
    if var_9 == var_5 + 1 :
        var_0 [ var_11 ] = 0
        var_7 , var_11 = var_7 - 1 , var_11 - 1
    while ~ var_11 :
        if var_0 [ var_7 ] == 0 :
            var_0 [ var_11 ] = var_0 [ var_11 - 1 ] = var_0 [ var_7 ]
            var_11 -= 1
        else :
            var_0 [ var_11 ] = var_0 [ var_7 ]
        var_7 , var_11 = var_7 - 1 , var_11 - 1
