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.
Time complexity can be reduced for the average case from O(n^2) to O(n) by recording the last index of all encountered numbers in a dictionary (worst case remains at O(n^2)):
Minimum Distances
You are viewing a single comment's thread. Return to all comments →
Time complexity can be reduced for the average case from O(n^2) to O(n) by recording the last index of all encountered numbers in a dictionary (worst case remains at O(n^2)):