Talentd
FleetCode

869. Reordered Power of 2

Medium66.0% acceptance5 companies

You are given an integer n. We reorder the digits in any order (including the original order) such that the leading digit is not zero.

Return true if and only if we can do this so that the resulting number is a power of two.

Example 1:

Input: n = 1
Output: true

Example 2:

Input: n = 10
Output: false

Constraints:

  • 1 <= n <= 109
33:03
Still stuck?Read 3 approaches, or watch a walkthrough.
Open solution
Loading editor…
1class Solution:
2 def reorderedPowerOf2(self, n: int) -> bool:
3
Starter codePython 3Spaces: 4
Examples
Input
1
Input
10
Your code is saved on this device.Solution