beats 100%,using c++ 0 ms (aunikverma36@gmail.com)
Complexity
Time complexity:O(logn)

Space complexity:O(1)
Code


# Complexity
- Time complexity:O(logn)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
    string baseNeg2(int n) {
        string ans = "";
        while (n) {
            ans = to_string(n & 1) + ans;
            n = -(n >> 1);//for base -2
        }
        return (ans == "" ? "0" : ans);//if n == 0 return "0"
    }
};
```
['C++']