• + 0 comments

    Python Here is the magic

    def minimumDistances(a):
        d = {key:abs(a.index(key) - (len(a)-1-a[::-1].index(key))) for key in set(a) if a.count(key)>1}
        val = min(d.values()) if len(d)>0 else -1
        return val