C++ | 0 ms | One Line Solution using XOR
\nclass Solution {\npublic:\n    int bitwiseComplement(int n) {\n        if(n==0) return 1;\n        \n        return (int)(pow(2,(int)log2(n) + 1) - 1) ^ n ;\n
```\nclass Solution {\npublic:\n    int bitwiseComplement(int n) {\n        if(n==0) return 1;\n        \n        return (int)(pow(2,(int)log2(n) + 1) - 1) ^ n ;\n    }\n};\n```\n\nExplanation: we have to make ***0101*** from 1010.\nwe observe, 1010 ^ *0101* = 1111\nHence,\nXOR with 1010 on both sides we get (we know that a^a = 0 and a^0 = a),\n1010^*0101*^1010 = 1111^1010\n=> ***0101*** = 1010^1111
['Bit Manipulation', 'C']