Dynamic Programming
Cache a well-defined state and combine smaller subproblems.
Recognition signal
Different decision paths lead back to the same smaller question.
Method
Define the state, base values, transition, computation order and final state.
Worked example
With steps 1 or 2, ways[4] = ways[3] + ways[2] = 3 + 2.
Common mistake
A recurrence can be correct while its loop visits dependencies too late.