Given an input array, remove all any duplicate occurrences and return the array.
Anonymous
private static int[] removeDuplicates(int[] a) { int[] b = new int[a.length]; Map map = new HashMap(); int index = 0; for(int i = 0; i < a.length; i++) { if(!map.containsKey(a[i])) { map.put(a[i], 1); b[index] = a[i]; index++; } } return b; }
Check out your Company Bowl for anonymous work chats.