```
int* singleNumber(int* nums, int numsSize, int* returnSize) {
int i, *ret = calloc(*returnSize = 2, sizeof(int));
for(i = 0; i < numsSize; ret[0] ^= nums[i++]);
for(i = 0; i < numsSize; i++)
if(nums[i] & ret[0] & -ret[0])
ret[1] ^= nums[i];
ret[0] ^= ret[1];
return ret;
}
```

However I posted this question some days ago at https://leetcode.com/discuss/48119/single-number-iii .

- x = xor of each element in the list ==> x = a xor b
- a != b => there are at least one 1-bit in x
- take an arbitrary 1-bit (which means a and b is different on this bit), the elements in the array can be classified into two groups according to this bit: one of them contains a, the other contains b.
- a = xor of each element in the list which the corresponding bit = 0
- b = a xor x