3 line easy short | c++ code | math | O(log2(n))
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \njust find the just grea
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\njust find the just greater number than **n** which is power of 2 then subtact 1 from it.\nthen return xor of both\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int bitwiseComplement(int n) {\n        unsigned int b=0,k=0;\n        while(k<=n)b++,k=pow(2,b);\n        return (k-1)^n;\n    }\n};\n```\n# Complexity\n- Time complexity: O(log2(n))\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n
['Bit Manipulation', 'C++']