C++ | Bit Manipulation | O(N)
Intuition\n\n\n# Approach\nBit Manipulation\n\n# Complexity\n- Time complexity: O(n)\n\n- Space complexity: O(1)\n\n# Code\n\nclass Solution {\npublic:\n    int
# Intuition\n\n\n# Approach\nBit Manipulation\n\n# Complexity\n- Time complexity: O(n)\n\n- Space complexity: O(1)\n\n# Code\n```\nclass Solution {\npublic:\n    int bitwiseComplement(int n) {\n        int x=0,m=1;\n        if(n==0) return 1;\n        while(n){\n            if(!(n&1)) x+=m;\n            m*=2;\n            n>>=1;\n        }\n        return x;\n    }\n};\n```
['C++']