ElasticSoftware Engineer · Phone ScreenCodemia practiceCount shortest distance in array
Given an array of integers, write a function to calculate the shortest distance between any two occurrences of the same integer. The function should return the minimum distance found, or -1 if no integer appears more than once. The input will be an array of integers, and the output should be a single integer representing the shortest distance.