C++ Solution || Runtime 0ms || Beats 100% ||
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:\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\n# Code\n```\nclass Solution {\npublic:\n    int bitwiseComplement(int n) {\n        \n    int temp=n;\n    int mask=0;\n    int ans;\n    if(n==0)\n    {\n        ans=1;\n    }\n    else\n    {\n        while(temp!=0)\n        {\n            mask= (mask<<1) | 1;\n            temp=temp>>1;\n        }\n        ans=(~n) & mask;\n    }\n    return ans;\n\n\n    }\n};\n```
['C++']