"class Solution {

public int findComplement(int num) {

num=~num; //flip all the bits but this flips most significant 0's to 1's which we don't want.

int checker = 1<<31; //number with highest set bit which will keep on shifting

while((num&checker)!=0){//while most significant bits are 1 flip them

num^=checker;/flipping most significant 1 bits till we find first 0 bit

checker>>>=1;

}

return num;

}

}"