// Path: src/main/java/com/hackerrank/MinimumDistances.java
// static int minimumDistance(int[] arr) {
//     Map<Integer, Integer> entries = new HashMap<>();
//     int min = Integer.MAX_VALUE;
//     for (int i = 0; i < arr.length; i++) {
//         if (!entries.containsKey(arr[i])) {
//             entries.put(arr[i], i);
//         } else {
//             int dist = i - (entries.get(arr[i]));
//             if (min > dist) {
//                 min = dist;
//             }
//         }
//     }
//     return min == Integer.MAX_VALUE ? -1 : min;
// }


import org.junit.Test;
import static com.hackerrank.MinimumDistances.minimumDistance;
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
package com.hackerrank;



public class MinimumDistancesTest {

    @Test
    public void firstTestCase() {
// Path: src/main/java/com/hackerrank/MinimumDistances.java
// static int minimumDistance(int[] arr) {
//     Map<Integer, Integer> entries = new HashMap<>();
//     int min = Integer.MAX_VALUE;
//     for (int i = 0; i < arr.length; i++) {
//         if (!entries.containsKey(arr[i])) {
//             entries.put(arr[i], i);
//         } else {
//             int dist = i - (entries.get(arr[i]));
//             if (min > dist) {
//                 min = dist;
//             }
//         }
//     }
//     return min == Integer.MAX_VALUE ? -1 : min;
// }


// Path: src/test/java/com/hackerrank/MinimumDistancesTest.java
import org.junit.Test;
import static com.hackerrank.MinimumDistances.minimumDistance;
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;

package com.hackerrank;



public class MinimumDistancesTest {

    @Test
    public void firstTestCase() {
        assertThat(minimumDistance(new int[]{7, 1, 3, 4, 1, 7})).isEqualTo(3);