<qiyuangong>219_Contains_Duplicate_II_1.py
def containsNearbyDuplicate( nums, k):
    check = {}
    for i in range(len(nums)):
        try:
            check[nums[i]].append(i)
        except:
            check[nums[i]] = [i]
    
    
    for _, v in check.items():
        if len(v) >= 2:
            pos = 0
            while pos + 1 < len(v):
                if v[pos + 1] - v[pos] <= k:
                    return True
                pos += 1
    return False
def sample_funcname ( var_0 , var_1 ) :
    var_2 = { }
    for var_5 in range ( len ( var_0 ) ) :
        try :
            var_2 [ var_0 [ var_5 ] ].append ( var_5 )
        except :
            var_2 [ var_0 [ var_5 ] ] = [ var_5 ]
    for var_8 , var_9 in var_2.items ( ) :
        if len ( var_9 ) >= 2 :
            var_12 = 0
            while var_12 + 1 < len ( var_9 ) :
                if var_9 [ var_12 + 1 ] - var_9 [ var_12 ] <= var_1 :
                    return True
                var_12 += 1
    return False
