How to write an algorithm to find the shortest distance between two elements of an array in Swift
Today I was presented to this problem. Basically given a list of elements, I’d have to find the nearest distance between two elements of that list.
You can see an example of given list. Notice that we’re not talking about a set, which means that elements could possibly repeat.