Ideas:
1. Take the highest digit of the number and fill it with zeros, then shift one place to the left, and then subtract one
2. Invert the target number
3. With
class Solution { public int findComplement(int num) { int mask=(Integer.highestOneBit(num)<<1)-1; num=~num; return mask# } }