We define the distance between two array values as the number of indices between the two values. Given , find the minimum distance between any pair of equal elements in the array. If no such value exists, print .
For example, if , there are two matching pairs of values: . The indices of the 's are and , so their distance is . The indices of the 's are and , so their distance is .
Complete the minimumDistances function in the editor below. It should return the minimum distance between any two matching elements.
minimumDistances has the following parameter(s):
a: an array of integers
The first line contains an integer , the size of array .
The second line contains space-separated integers .
Print a single integer denoting the minimum in . If no such value exists, print .