(newest approach) c++ 100% 0 ms without converting number into binary
\nclass Solution {\npublic:\n    int power_floor( int n)\n    {\n       \n        if((n!=0) &&!(n & (n-1)))\n        {\n            return n;\n        }\n      
```\nclass Solution {\npublic:\n    int power_floor( int n)\n    {\n       \n        if((n!=0) &&!(n & (n-1)))\n        {\n            return n;\n        }\n        int count=0;\n        while(n!=0)\n        {\n            n>>=1;\n            count+=1;\n        }\n        return 1<<count;\n    }\n    int bitwiseComplement(int n) {\n if(n==0)\n        {\n            return 1;\n        }\n        if(n==1)\n        {\n            return 0;\n        }\n      int k = power_floor(n);\n        if(k-n==0)\n        {\n            return k-1;\n        }\n        else\n        {\n            return k-n-1;\n        }\n    }\n};\n```
['Bit Manipulation']