Path Sum
Recognize the pattern
Brute force idea
The naive version of Path Sum sounds like this: Enumerate all root-to-leaf paths, check sums — same complexity but less elegant. That direct path helps you understand the question, but it tends to treat every possibility as brand new instead of learning from earlier steps.
Better approach
A calmer way to see Path Sum is this: DFS: subtract node value from target, check if leaf with remaining = 0. 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 Path Sum is this: At each node, reduce the target by the node's value — a leaf with remaining target 0 means success. If that remains true after every update, the rest of the reasoning has a stable place to stand.
Watch out for
One easy way to drift off course in Path Sum is this: Checking non-leaf nodes — the path must go all the way to a leaf (no children). The fix is usually to return to the meaning of each move, not just the steps themselves.