An integer array is given. In that array, 3 unique numbers have number of occurrence as even. Rest have only one occurrence. Is there any way to find those numbers using XOR logic. Also the given array is of n+3 elements. All elements of the array are in range 1 to n.
for eg: arr= {4, 2, 4, 5, 2, 3, 1, 5} where n = 5 here unique numbers with even occurrence are 2, 4 and 5
I did the XOR of array numbers along with xor of range 1 to n. That gave a number which is the answer of XOR of final three unique numbers. In case of two numbers we can check the set bit and proceed to find the numbers. But what about three numbers. Is there any way to do this.
I know hashing can be used to solve the problem. I am looking for XOR approach to solve the problem.