You are viewing a single comment's thread. Return to all comments →
def minimumDistances(arr): dct={} for i in range(len(a)): if arr[i] in dct: dct[arr[i]].append(i) else: dct[arr[i]]=[i] ans=[] #print(dct) for lis in dct: if len(dct[lis])>1: ans.append(abs(dct[lis][0]-dct[lis][1])) #print(ans) if ans == []: return '-1' return min(ans)
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 →