5 line c++


  • 0
    Y

    class Solution {
    public:
    int findComplement(int num) {
    int m=num/2,sum=0;
    for(int i=0;i<=m;i++)
    sum+=pow(2,i);
    int rst=num^sum;
    return rst;
    }
    };


Log in to reply
 

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