<doocs>1562.Find Latest Group of Size M_1.py
def findLatestStep( arr: List[int], m: int) -> int:
    n = len(arr)
    if m == n:
        return n
    cnt = [0] * (n + 2)
    ans = -1
    for i, v in enumerate(arr):
        v -= 1
        l, r = cnt[v - 1], cnt[v + 1]
        if l == m or r == m:
            ans = i
        cnt[v - l] = cnt[v + r] = l + r + 1
    return ans
def sample_funcname ( var_0 : List [ int ] , var_3 : int ) -> int :
    var_5 = len ( var_0 )
    if var_3 == var_5 :
        return var_5
    var_8 = [ 0 ] * ( var_5 + 2 )
    var_10 = - 1
    for var_12 , var_13 in enumerate ( var_0 ) :
        var_13 -= 1
        var_14 , var_15 = var_8 [ var_13 - 1 ] , var_8 [ var_13 + 1 ]
        if var_14 == var_3 or var_15 == var_3 :
            var_10 = var_12
        var_8 [ var_13 - var_14 ] = var_8 [ var_13 + var_15 ] = var_14 + var_15 + 1
    return var_10
