You are viewing a single comment's thread. Return to all comments →
My solution in python.
def minimumDistances(a): uniqueItems = set(a) minDistance = -1 for item in uniqueItems: calc = [] for index,item2 in enumerate(a): if (item2 == item): calc.append(index) if len(calc) == 1: continue else: distance = calc[1] - calc[0] if minDistance == -1: minDistance = distance elif distance < minDistance: minDistance = distance return minDistance
Seems like cookies are disabled on this browser, please enable them to open this website
Minimum Distances
You are viewing a single comment's thread. Return to all comments →
My solution in python.