Number compliment c++


  • 0
    T

    '''
    class Solution {
    public:
    int findComplement(int num) {
    int result=0;
    for(int i = 0; num != 0; i++) {
    result += ((1 & num) ^ 1)<<i;
    num>>=1;
    }
    return result;
    }
    };
    '''


Log in to reply
 

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