From ed8a1e6a5dd32eb965fc62ef0f6758359f0a5162 Mon Sep 17 00:00:00 2001 From: anneCoder1805 <66819522+anneCoder1805@users.noreply.github.com> Date: Sun, 18 Oct 2020 20:09:29 +0530 Subject: [PATCH] Create 0869_Reordered_Power_of_2.py --- LeetCode/0869_Reordered_Power_of_2.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 LeetCode/0869_Reordered_Power_of_2.py diff --git a/LeetCode/0869_Reordered_Power_of_2.py b/LeetCode/0869_Reordered_Power_of_2.py new file mode 100644 index 0000000..1c58eb3 --- /dev/null +++ b/LeetCode/0869_Reordered_Power_of_2.py @@ -0,0 +1,15 @@ +import math +import itertools +class Solution(object): + def reorderedPowerOf2(self, N): + """ + :type N: int + :rtype: bool + """ + nums = ["".join(x) for x in list(itertools.permutations(list(str(N))))] + for n in nums: + if n[0]!='0': + a = int(math.log(int(n),2)) + if 2**a == int(n): + return True + return False