Browse Curriculum

The Dynamic Programming Pattern

Solve each distinct subproblem once and reuse the answer. Memoization caches results on top of the natural recursion; tabulation fills a table bottom-up. Both depend on finding a recurrence that expresses a problem in terms of smaller versions of itself.

9
Interactive problems
2
Free to open

How to recognise a dynamic programming problem

The problem asks for a count of ways, a minimum or maximum over choices, or whether something is achievable — and a brute-force recursion would solve the same subproblem repeatedly. Overlapping subproblems plus optimal substructure is the signature.

Time and space complexity

Usually O(states × transitions). A 1D DP over n items is O(n); knapsack and most string DP are O(n × m). Space often reduces to one or two rows.

Dynamic Programming practice problems

Each problem pairs a worked explanation with an interactive visualizer you step through yourself, plus the implementation in JavaScript, Python, Java and C++.


Related patterns and concepts

The underlying technique is covered from first principles in the dynamic programming lesson in the DSA visualizer curriculum. Dynamic Programming is one of the 16 coding interview patterns, and its problems also appear in the DSA 75 interview sprint.