Dynamic Programming

DP organized by state shape — Linear, 2D Grid, Knapsack, Intervals, Tree DP, Bitmask.

1 min readInterview · DSA Patterns

DP isn't one technique — it's a family of techniques sharing a single insight: overlapping subproblems + optimal substructure → memoize. Splitting DP by state shape (1D? 2D? on a tree? on a bitmask?) makes it teachable. Lump them together and DP is mysticism.

Six pages, in roughly the order you should learn them:


How to think about a DP problem

The state shape is the question. Once you know the state shape, the transition usually writes itself.

Finished reading?

Mark it done to track your progress in Interview.