Trains the technique from
LeetCode 342Power of FourThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
Return true when the whole number n is a power of four, meaning n equals 4 raised to some whole power of zero or more.
Example 1
Four multiplied by itself three times comes to 64.
Example 2
Eight is a power of two but not of four: dividing it by four leaves two behind.
Example 3
Every power of four is at least one, so nothing this small qualifies.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def is_power_of_four(n: int) -> bool:public boolean isPowerOfFour(int n)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.