[ Python ] ✅✅ Simple Python Solution Using Two Different Approach 🥳✌👍
If You like the Solution, Don\'t Forget To UpVote Me, Please UpVote! \uD83D\uDD3C\uD83D\uDE4F\n# 1. First Apporach Using Permutation Concept : \n# Runtime: 8288
# If You like the Solution, Don\'t Forget To UpVote Me, Please UpVote! \uD83D\uDD3C\uD83D\uDE4F\n# 1. First Apporach Using Permutation Concept : \n# Runtime: 8288 ms, faster than 5.35% of Python3 online submissions for Reordered Power of 2.\n# Memory Usage: 28.1 MB, less than 11.23% of Python3 online submissions for Reordered Power of 2.\n\tclass Solution:\n\t\tdef reorderedPowerOf2(self, n: int) -> bool:\n\n\t\t\tall_permutations = [] \n\n\t\t\tfor single_number in itertools.permutations(str(n)):\n\n\t\t\t\tif single_number[0] != \'0\':\n\n\t\t\t\t\tnum = int(\'\'.join(single_number))\n\n\t\t\t\t\tall_permutations.append(num)\n\n\t\t\tfor i in range(32):\n\n\t\t\t\tif 2**i in all_permutations:\n\t\t\t\t\treturn True\n\n\t\t\treturn False\n# 2. Second Approach With HashMap Or Dictionary with Sorting : \n# Runtime: 56 ms, faster than 60.96% of Python3 online submissions for Reordered Power of 2.\n# Memory Usage: 13.7 MB, less than 96.79% of Python3 online submissions for Reordered Power of 2.\n\n\tclass Solution:\n\t\tdef reorderedPowerOf2(self, n: int) -> bool:\n\n\t\t\tnum = sorted(str(n))\n\n\t\t\tfor i in range(32):\n\n\t\t\t\tcurrent_num = sorted(str(2**i))\n\n\t\t\t\tif num == current_num:\n\t\t\t\t\treturn True\n\n\t\t\treturn False\n# Thank You \uD83E\uDD73\u270C\uD83D\uDC4D
['Sorting', 'Probability and Statistics', 'Python', 'Python3']