Java Simple Solution for Base 2 and Base -2
\n    public String base2(int N){\n        String res = "";\n        while(N != 0){\n            res = (N&1) + res;\n            N = N >> 1;\n        }\n       
```\n    public String base2(int N){\n        String res = "";\n        while(N != 0){\n            res = (N&1) + res;\n            N = N >> 1;\n        }\n        return res.length() > 0 ? res: "0";\n    }\n    public String baseNeg2(int N){\n        String res = "";\n        while(N != 0){\n            res = (N&1) + res;\n            N = -(N >> 1);\n        }\n        return res.length() > 0 ? res: "0";\n    }\n```
[]