You are given an array with n positive integers where all values in the array are repeated except for one. Return the one that is not repeated.
Anonymous
public static int notRepeated(int[] given) { Map m = new HashMap(); for(i=0; i < given.length; i++) { if(m.get(given[i])) { m.put(given[i], 2); } else m.put(given[i], 1); for(x:m) { if(x == 1) return x; } } }
Check out your Company Bowl for anonymous work chats.