• + 0 comments
    def minimumDistances(a):
        dist = float('inf')
        for i in range(len(a)):
            if a[i] in a[i+1:]:
                b = a.index(a[i],i+1,len(a))
                dist = min(dist,abs(i-b))
        if dist == float('inf'):
            return -1 
        else:
            return dist