Beat 89.07% of java submissions.


  • 0
    C
    public int findComplement(int num) {
            int multiplier = 1;
            int result = 0;
            while (num > 0) {
                if (num%2 == 0) {
                    result += multiplier;
                }
                multiplier = multiplier << 1;
                num = num >> 1;
            }
            return result;
        }

Log in to reply
 

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