Product of Array Except Self
Recognize the pattern
Brute force idea
A straightforward first read of Product of Array Except Self is this: For each element, multiply all others. 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
The real unlock in Product of Array Except Self comes when you notice this: Two passes: left-to-right prefix products, then right-to-left suffix products. Instead of recomputing the world every time, you preserve just enough context to let the next decision become obvious.
Key invariant
The compass for Product of Array Except Self is this: result[i] = product of all elements to the left × product of all elements to the right. As long as that statement keeps holding, you can trust the steps built on top of it.
Watch out for
A common way to get lost in Product of Array Except Self is this: Trying to use division — the problem explicitly forbids it, and zeros break division anyway. Most mistakes here are not about syntax; they come from losing track of what your state, pointer, or structure is supposed to mean.