Recursive NOT Bit Operation


  • 0
    B

    Not using bit operation

    public:
        int findComplement(int num) {
            if(num==0) return 0;
            return 2*findComplement(num/2)+(1-num%2);
        }
    };
    

Log in to reply
 

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