4 lines C++,easyunderstand


  • 0
    L

    class Solution {
    public:
    int findComplement(int num)
    {
    int i=0;
    while(pow(2,i)<=num)
    ++i;
    return pow(2,i)-1-num;
    }
    };


Log in to reply
 

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