Target Sum
Recognize the pattern
Brute force idea
If you approach Target Sum in the most literal way possible, you get this: Try all 2^n sign assignments. Each number is either + or. giving binary choices. It is a fair place to begin because it matches the surface of the question, yet it does not capture the deeper structure that makes the problem simpler.
Better approach
The deeper shift in Target Sum is this: Transform: find a subset P where sum(P) = (totalSum + target) / 2. This reduces to subset sum counting. dp[j] += dp[j - num] for each number. Once you hold onto the right piece of information from moment to moment, the problem feels less like trial and error and more like following a shape that was there all along.
Key invariant
The truth you want to protect throughout Target Sum is this: If positive numbers sum to P and negatives to N, then P - N = target and P + N = totalSum. So P = (totalSum + target) / 2. Counting subsets with this sum counts the valid assignments. 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 Target Sum is this: Not seeing the reduction to subset sum — the +/- assignment can be split into a positive set and negative set, transforming the problem algebraically. Most mistakes here are not about syntax; they come from losing track of what your state, pointer, or structure is supposed to mean.