Removing duplicate values from an array
Suggestion: 

public static Integer[] removeDuplicates(Integer[] arr) {
  return new HashSet&lt;Integer&gt;(Arrays.asList(arr)).toArray(new Integer[0]);
}


Another solution might be:

public static int[] removeDuplicates(int[] arr) {
  Set&lt;Integer&gt; alreadyPresent = new HashSet&lt;Integer&gt;();
  int[] whitelist = new int[0];

  for (int nextElem : arr) {
    if (!alreadyPresent.contains(nextElem)) {
      whitelist = Arrays.copyOf(whitelist, whitelist.length + 1);
      whitelist[whitelist.length - 1] = nextElem;
      alreadyPresent.add(nextElem);
    }
  }

  return whitelist;
}


Here you only iterate once via arr.