# Find the number which is not repeated in Array of integers

Interview Question:Find the number which is not repeated in Array of integers, others are present for two times.

**(Solve it in time complexity O(n) and no extra memory usage)**

X-OR all numbers of the array.

X-OR of 2 same numbers is 0

&

X-OR of 0 and a number is that number.

So all repeated numbers would be X-ORed to 0.

And X-OR of 0 and unique number would be that unique number.

We don’t have direct function for XOR in C.

XOR of A and B can be written as A AND neg B OR B AND neg A.

XOR(A,B) = A&~B OR B&~A

#include <stdio.h> int XOR(int x,int y){ return (x&~y) | (~x&y); } int main(){ int arr [] = { 1,4,2,5,6,4,1,2,5 } ,ans=0; int size = sizeof(arr)/sizeof(int),i; for(i=0;i<size;i++){ ans = XOR(ans,arr[i]); } printf("%d",ans); return 0; }