Reordered Power of 2
MediumMathhashing
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
Given a positive integer n, you may rearrange its decimal digits into any order, as long as the resulting number does not start with a 0.
Return true if at least one such arrangement (including the original order) is a power of two, and false otherwise.
Examples
Input: n = 1
Output: true
1 = 2^0.
Input: n = 10
Output: false
The only arrangement without a leading zero is 10, which is not a power of two.
Input: n = 46
Output: true
Reordering gives 64 = 2^6.
Constraints
- `1 <= n <= 10^9`
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.