@@ -0,0 +1,940 @@
+/**%0A * %0A */%0Apackage algorithms.implementation;%0A%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0Aimport java.util.Scanner;%0A%0A/**%0A * Challenge: https://www.hackerrank.com/challenges/minimum-distances/%0A * %0A * @author Sudharsanan Muralidharan%0A */%0Apublic class MinimumDistances %7B%0A  public static void main(String%5B%5D args) %7B%0A    Scanner in = new Scanner(System.in);%0A    int n = in.nextInt();%0A    int minDistance = Integer.MAX_VALUE;%0A    Map%3CInteger, Integer%3E indexesMap = new HashMap%3CInteger, Integer%3E();%0A%0A    for (int i = 0; i %3C n; i++) %7B%0A      int val = in.nextInt();%0A      if (indexesMap.containsKey(val)) %7B%0A        int distance = Math.abs(i - indexesMap.get(val));%0A        if (distance %3C minDistance) %7B%0A          minDistance = distance;%0A        %7D%0A        indexesMap.put(val, i);%0A      %7D else %7B%0A        indexesMap.put(val, i);%0A      %7D%0A    %7D%0A    %0A    System.out.println(minDistance == Integer.MAX_VALUE ? -1 : minDistance);%0A    in.close();%0A  %7D%0A%7D%0A

Add solution for MinimumDistances