


Consider the array be 1,6,4,6,2,4,2
The integers 2, 4, 6 occur twice and only the integer 1 occurs once.
The first line contains an integer ‘N’, representing the length of the array.
The second line contains N space-separated integers of the array A.
Print the only integer which occurs once in the array.
You do not need to print anything, it has already been taken care of. Just implement the given function.
Explanation:
The key idea is while iterating the array count frequencies of all elements by hashing them.
And after iterating check which element occurs only once by looking at its frequency.
Algorithm:
Explanation:
The idea to xor all the elements in the array and return the final xor value. The idea is based on the following two facts :
In the problem, we will have (N-1)/2 values that occur twice which will result in 0 after xor. And the only value which will contribute to the final result is the integer occurring only once.
Algorithm: