<qiyuangong>697_Degree_of_an_Array_2.py
def findShortestSubArray( nums):
    left, right, count = {}, {}, {}
    for i, x in enumerate(nums):
        if x not in left: left[x] = i
        right[x] = i
        count[x] = count.get(x, 0) + 1
    
    ans = len(nums)
    degree = max(count.values())
    for x in count:
        if count[x] == degree:
            ans = min(ans, right[x] - left[x] + 1)
    
    return ans
def sample_funcname ( var_0 ) :
    var_1 , var_2 , var_3 = { } , { } , { }
    for var_5 , var_6 in enumerate ( var_0 ) :
        if var_6 not in var_1 : var_1 [ var_6 ] = var_5
        var_2 [ var_6 ] = var_5
        var_3 [ var_6 ] = var_3.get ( var_6 , 0 ) + 1
    var_11 = len ( var_0 )
    var_14 = max ( var_3.values ( ) )
    for var_6 in var_3 :
        if var_3 [ var_6 ] == var_14 :
            var_11 = min ( var_11 , var_2 [ var_6 ] - var_1 [ var_6 ] + 1 )
    return var_11
