🔥 Python || Easily Understood ✅ || Faster than 96% || Fast
Appreciate if you could upvote this solution\n\nSince the maximun of n is 10^9 and the len(str(10**9)) is 10 which is complicated to get all the combinations of
**Appreciate if you could upvote this solution**\n\nSince the maximun of `n` is 10^9 and the `len(str(10**9))` is 10 which is complicated to get all the combinations of the digits.\n\nThus, we resolved this questions to:\n**If the digit combination of n match the digit combinations of all the power of 2**\n\nThen, it is much more easier as we need to compare n with 30 numbers only which are\n```\n2^0\n2^1\n... \n2^30\n```\n\nFor the digit combinations, there are 2 methons to handle:\n\n1) Dict: Count the occurrences of all digits\n```\nclass Solution:\n    def reorderedPowerOf2(self, n: int) -> bool:\n        return sorted(str(n)) in [Counter(str(1 << i)) for i in range(30)] \n```\n\n2) String: Sort all the digits\n```\nclass Solution:\n    def reorderedPowerOf2(self, n: int) -> bool:\n        return sorted(str(n)) in [sorted(str(1 << i)) for i in range(30)] \n```\n\n**Time Complexity**: \n - Counter -  `O(n)`\n - Sort - `O(nlogn)`\n\n**Space Complexity**: `O(1)`\n<br />\n
['Python']