XOR toggles the bits and will form a number that will have set bits at the places where the numbers bits differ eg : 010 ^ 111 = 101. . . diff of bits = count of 1 's = 2
int xor = arr [ i ] ^ arr [ j ] ;