Number Complement Solution


  • 0
    P

    '''
    class Solution {
    public int findComplement(int num) {
    long power = 1;

        while (power <= num) {
            power = power << 1;
        }
        
        return (int)(num ^ (power - 1));
    }
    

    }
    '''


Log in to reply
 

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