easy solution using math calculation in cpp
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(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    string baseNeg2(int n) {\n        if(n == 0) \n            return "0";\n        string ans = "";\n        while(n != 0)\n        {\n            int rem = n % -2;\n            if(rem < 0)\n            {\n                rem += 2;\n                n--;\n            }\n            ans = to_string(rem) + ans;\n            n = n / -2;\n        }\n        return ans;\n    }\n};\n```
['C++']