Another 3 line C++


  • 0
    M
    int findComplement(int num) {
        unsigned int bigger = 1;
        while (bigger <= (unsigned int)num) bigger <<= 1;
        return (int)(bigger - (unsigned int)num) - 1;
    }

Log in to reply
 

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