Рет қаралды 10,603
In an integer array, except for one number which occurs odd number of times, all other numbers occur even number of times. Find the number.
Example:
Input: 2 3 4 3 1 4 5 1 4 2 5
Output: 4
Algorithm:
Initialize result = 0.
Iterate over the array and XOR result with each element of the input array.
Once iteration over the array is done, print result as the output.
Order of the Algorithm:
Time Complexity: O(n)
Space Complexity: O(1)
Code and Algorithm Visualization:
Coming Soon on www.ideserve.co.in. Stay tuned!
Website: www.ideserve.co.in
Facebook: / ideserve.co.in