We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
defminimumDistances(a):# Write your code herepairs=set()foriina:ifa.count(i)==2:pairs.add(i)ifnotpairs:return-1distances=[]forvalinpairs:indexes=[]fori,vinenumerate(a):ifv==val:indexes.append(i)distances.append(indexes[1]-indexes[0])returnmin(distances)
Cookie support is required to access HackerRank
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 →