Python
As N is bounded by 10^9 we need to check at most the 30-th power of 2. For each power of 2 we count the occurrence of every digit and store it in an array of si
As `N` is bounded by 10^9 we need to check at most the 30-th power of 2. For each power of 2 we count the occurrence of every digit and store it in an array of size 10 (from 0,...,9). If for any power of 2 the count matches that of `N` we return True. Else return False.\n\nTime: `O(1)`\nSpace: `O(1)`\n\n```python\nclass Solution:\n    def reorderedPowerOf2(self, N):\n        def is_equal(c1, c2):\n            return sum(abs(x-y) for x,y in zip(c1,c2))==0\n        \n        \n        def count(n):\n            c = [0]*10\n            while n:\n                c[n % 10] += 1\n                n //= 10\n            return c\n        \n        \n        c1 = count(N)\n        for i in range(31):\n            c2 = count(2**i)\n            if is_equal(c1, c2):\n                return True\n        return False\n```
[]