Given an array of integers, every element appears twice except for one. Find that single one.
Note:
Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?
最快算法:
int singleNumber(int a[], int n)
//xor all numbers, the left over number would be the non repeated one
// since the equl numbers cancel out each others bits
int num = 0;
for (int i = 0; i < n; ++i) {
num ^= a[i];
}
return num;
}