Find Even Occurring Element
The question
Given an integer array, one element occurs even number of times and all others have odd occurrences. Find the element with even occurrences.
My answer
The first thing I thought of was using XOR, but then I realized that I am looking for the even number so it won’t actually work. My next idea was to use a hashtable:
1 – Start on the first elements and create a hashtable with the number of times each character is found
2 – Look for the even number in the hashtable