Easy C++ solution || Beats 100% || 0ms solution || O(log(n)) solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(log(N))\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int bitwiseComplement(int n) {\n        if (n == 0)\n        return 1;\n        int num = n;\n        int mask = 0;\n        while(num)\n        {\n            mask = mask<<1 | 1;\n            num >>= 1;\n        }\n        return n ^ mask;\n    }\n};\n```
['C++']