Java Solution(With comments)
\npublic String baseNeg2(int n) {\n        if (n == 0)  {\n            return "0";\n        }\n\n        int base = -2;\n\n        StringBuilder ans = new Strin
```\npublic String baseNeg2(int n) {\n        if (n == 0)  {\n            return "0";\n        }\n\n        int base = -2;\n\n        StringBuilder ans = new StringBuilder();\n        while (n != 0)\n        {\n            // Remainder by negative base can be negative also\n            int remainder = n % base;\n            n /= base;\n\n            // if remainder is negative, add Math.abs(base) to it and add 1 to n\n            if (remainder < 0)\n            {\n                remainder += (-base);\n                n += 1;\n            }\n\n            // convert remainder to string add into the result\n            ans.insert(0, remainder);\n        }\n\n        return ans.toString();\n    }\n```
[]