C# Solution (Find Complement)


  • 0
    A
     public int  FindComplement(int num)
            {
                int mask = 0;
                int temp = num;
                while (temp != 0)
                {
                    mask = (mask << 1) | 1;
                    temp >>= 1;
                }
                return (-1 ^ num) & mask;
            }
    

Log in to reply
 

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