Tech with Nikola Tech with Nikola
Free PDF — 1 page

The DP Pattern
Flowchart

The hard part of dynamic programming isn't the code — it's deciding what the state is. Answer a few questions about the problem and the flowchart points you at one of five shapes.

From the creator of Tech With Nikola (67K+ subscribers, 2M+ video views)

Get the Free PDF
The DP Pattern Flowchart preview
1

Read the state off the problem statement

Five questions, checked in order of how obvious the hint is: two sequences? a grid with restricted moves? a subset hitting a target? a range that splits? one sequence leaning on earlier results? Each answer names the state.

2

An escape hatch for the ones that don't fit

When no branch matches, there's one underlying question to fall back on — what does the future still need to know? — plus the usual answers: an extra mode, a tree, a bitmask, or that it isn't dynamic programming at all.

3

All five recurrences, written out

Linear, grid, knapsack, alignment and interval — the actual formulas, with the index conventions that match how the states are drawn, so you're not translating between two versions of the same idea.

4

One sentence that locks it in

Once the chart points at a state, you write "dp of this means…" — and from there it's machinery you can practise: the recurrence, memoization, bottom-up.

Get the flowchart

Enter your email and I'll send you the PDF — plus the DP Cheatsheet, Git Cheatsheet and Senior Engineer Checklist.

No spam. Unsubscribe anytime.