1017. Convert to Base -2. O(log(n))
ApproachI sent my intuition to hell this time and just read about the negative number system https://en.wikipedia.org/wiki/Negative_base and just coded a plan d
# Approach
I sent my intuition to hell this time and just read about the negative number system $$ $$ https://en.wikipedia.org/wiki/Negative_base $$ $$ and just coded a plan described there.

# Complexity
- Time complexity: $$O(log(n))$$

- Space complexity: $$O(log(n))$$

# Code
```python []
class Solution(object):
    def baseNeg2(self, n):
        """
        :type n: int
        :rtype: str
        """
        if n == 0:
            return '0'
        v = ''
        while n != 0:
            r = n % (-2)
            n //= -2
            if r < 0:
                n += 1
                r += 2
            v = str(r) + v
        return v
```
['Python']