• + 0 comments

    Way to do it with out nested for loops

    def minimumDistances(a):
        # Write your code here
        values = []
        for i in a:
            start = a.index(i)
            if a.count(i) >= 2:
                #d=a.index(i, start+1)
                values.append(abs(a.index(i, start+1)-start))
                print(i)
        if values:
            return min(values)
        else:
            return -1