I read @zhiqing_xiao 's post to get an idea about the solution. His solution is really smart and elegant, but it took me a while to get understand how "diff &= -diff" works. I changed it a little bit to make it better understood, but it is totally based on his solution.

Instead of using the right-most "1" of diff, I used the left-most "1" to divide groups. This should also do the trick.

```
public class Solution {
public int[] singleNumber(int[] nums) {
int diff = 0;
for(int num: nums){
diff^=num;
}
diff = Integer.highestOneBit(diff);
int[] result = new int[2];
Arrays.fill(result,0);
for(int num: nums){
if((diff & num) == 0){
result[0] ^= num;
}
else{
result[1] ^= num;
}
}
return result;
}
```

}