step by step easy understand-Java


  • 0
    C
    public int findComplement(int num) {
            int res = 0;
            int count = 0;
            while(num != 0){
                if((num &1) == 1){
                    
                }else{
                    int mask = 1 << count;
                    res |= mask;
                }
                num = num >> 1;
                count ++;
            }
            return res;
        }

Log in to reply
 

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