Python Solution O(log(N)) (Mathematical approach for computing base of any number)
To find the base N of any given integer x, we divide the quotient we get by dividing x with N, with N again and again until we get the quotient 0 and the revers
To find the base `N` of any given integer `x`, we divide the **quotient** we get by dividing `x` with `N`, with `N` again and again until we get the quotient `0` and the ***reverse order of remainders*** is the **resultant value**. \n\nIn other words if we get `q` (Quotient) by dividing `x` with `N` the remainder is added into an Array or a List (we will use the remainder later). Divide `q` with `N` again until you reach a quotient `0`. As we stored the remainders, we reverse the List or Array we used to store and return the result as a string. ***(We are basically finding whether a bit is 0 or 1 for every division we perform, in the reverse order)***\n\n\tclass Solution:\n    def baseNeg2(self, n: int) -> str:\n        if n == 0:\n            return "0"\n        result = []\n        while n != 1 and n != -1:\n            if (n % -2) == -1:\n                result.append(\'1\')\n                n = n // -2\n                n += 1\n            else:\n                result.append(str(n % -2))\n                n = n//-2\n\n        if n == -1:\n            result.append(\'11\')\n        if n == 1:\n            result.append(\'1\')\n        return \'\'.join(result[::-1])\n
[]