There are 199 elements in array. It has only one distinct value? How will find this distinct value? Also for solution please tell about O(n)?How can you make it more efficient?
Anonymous
Above answer won't work on a data set like: {3, 3, 3, 2, 2, 12} where there's an odd number of non-unique values. The easy answer is that you could hash each element into a hash table which just contains a counter for each key add. Then you could go through the array again and look at the hash table to find the element that was only added once.
Check out your Company Bowl for anonymous work chats.