Because the question says ** You could assume no leading zero bit in the integer’s binary representation.**, I just try to find the right number to do the xor operation.

```
public int findComplement(int num) {
int compare = 1;
while (num > compare) {
compare <<= 1;
compare |= 1;
}
return num ^ compare;
}
```