• + 0 comments
    def minimumDistances(arr):
        dct={}
        for i in range(len(a)):
            if arr[i] in dct:
                dct[arr[i]].append(i)
            else:
                dct[arr[i]]=[i]
        ans=[]
        #print(dct)
        for lis in dct:
            if len(dct[lis])>1:
                ans.append(abs(dct[lis][0]-dct[lis][1]))
        #print(ans)
        if ans == []:
            return '-1'
        return min(ans)