Rookie C solution


  • 0
    H
    int findComplement(int num) {
        int out=0,i=0;
        for(i=0;num>0;num=num/2,i++)
        {
            out = out+(abs((num%2)-1)*pow(2,i));
        }
        return out;
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.