Power of Two
Recognize the pattern
Brute force idea
A straightforward first read of Power of Two is this: Divide by 2 repeatedly until you reach 1 or an odd number. Each division checks one bit, but you're doing it the slow way. That instinct is useful because it follows the prompt literally, but it usually keeps revisiting work the problem is begging you to organize.
Better approach
A calmer way to see Power of Two is this: n & (n - 1) == 0 checks if only one bit is set. A power of 2 in binary is 1 followed by zeros (e.g., 8 = 1000). Subtracting 1 flips all those zeros to ones (7 = 0111). AND-ing them gives 0 only when exactly one bit was set. The goal is not to be clever for its own sake, but to remember the one relationship that keeps the solution grounded as you move forward.
Key invariant
The truth you want to protect throughout Power of Two is this: A power of 2 has exactly one bit set in its binary representation. n & (n-1) clears the lowest set bit — if the result is 0, there was only one bit to begin with. If that remains true after every update, the rest of the reasoning has a stable place to stand.
Watch out for
A common way to get lost in Power of Two is this: Forgetting that 0 is not a power of 2 — you need n > 0 as an additional check, since 0 & (-1) = 0. Most mistakes here are not about syntax; they come from losing track of what your state, pointer, or structure is supposed to mean.