base -1 
IntuitionThe algorithm converts a given integer ( n ) into its base (-2) representation by iteratively determining the least significant digit (LSD) based on wh
# Intuition
The algorithm converts a given integer \( n \) into its base \(-2\) representation by iteratively determining the least significant digit (LSD) based on whether \( n \) is even or odd. If \( n \) is even, the digit is \( 0 \); if odd, the digit is \( 1 \). The number is then updated by dividing it by \(-2\), with special handling when \( n \) is odd to ensure the correct alternating sign of place values in the negative base system. This process continues until \( n \) becomes zero. The resulting digits are accumulated in a string and returned. The algorithm efficiently constructs the base \(-2\) representation with a time complexity of \( O(\log n) \), where each step reduces the number by half.



# Complexity
- Time complexity:
$$O(logn)$$

- Space complexity:
$$O(logn)$$

# Code
```python3 []
class Solution:
    def baseNeg2(self, n: int) -> str:

        ans = ""

        num = n 
        if n == 0 :
            return "0"
            
        while num != 0 :
            if num % 2 == 0 :
                ans = "0" + ans
                num = (num / 2) * (-1)
            
            elif num % 2 == 1 :
                ans = "1" + ans 
                num = ((num -1) / 2 ) * (-1)
            else : continue 
        
        return ans 




```
['Python3']