Leetcode 900 Solution

This article provides solution to leetcode question 900 (reordered-power-of-2)

https://leetcode.com/problems/reordered-power-of-2

Solution

class Solution:
    def reorderedPowerOf2(self, N: int) -> bool:
        k = 1
        while len(str(k)) <= len(str(N)):
            if sorted(str(k)) == sorted(str(N)):
                return True
            k *= 2
        return False