JAVA | O(n) | Beginner Friendly | Faster 100%
Please UpVote Me\nSimply O(n) Solution\n# PLEASEEEEEEE\n.\n# Code\n\nclass Solution {\n    public String baseNeg2(int n) {\n        if (n == 0) return "0";\n   
# **Please UpVote Me**\nSimply O(n) Solution\n# **$$PLEASEEEEEEE$$**\n.\n# Code\n```\nclass Solution {\n    public String baseNeg2(int n) {\n        if (n == 0) return "0";\n        StringBuilder sb = new StringBuilder();\n\n        while (n != 0) {\n            int remain = n % -2;\n            n /= -2;\n            if (remain < 0) {\n                remain += 2;\n                n += 1;\n            }\n            sb.append(remain);\n        }\n\n        return sb.reverse().toString();\n    }\n}\n```
['Java']