For a given array A containing numbers from 1 to N, I want to find the pair of numbers (x,y) which is repeated and missing. Example A = [1, 3, 3] then x = 3 and y = 2.
While I know that this problem can be solved by taking the xor approach mentioned here https://stackoverflow.com/a/5767648/5031518. I am failing to understand the last part of the solution where the values of x and y are extracted from x ^ y by splitting the array based on a set bit.
It would be helpful if someone can explain me why the xor of two list results in the value of x and y respectively.