You are viewing a single comment's thread. Return to all comments →
def minimumDistances(a): min_distance = length = len(a) d = dict() for index, el in enumerate(a): distance = abs(index - d.setdefault(el, index)) if distance: min_distance = min(distance, min_distance) if length == min_distance: return -1 return min_distance
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 →