#869

Reordered Power of 2

specialist · 635 · lc medium +30 · verified · 66% accepted · 2,541 likes · top 71%

Description

You are given a positive integer n. You may rearrange its digits in any order, provided the resulting number does not have a leading zero.

Return true if and only if some such rearrangement equals a power of two.

Example 1:

Input: n = 1
Output: true

Example 2:

Input: n = 10
Output: false

Code

1
2
3