Skip to content

Dynamic programming problem sheet

A curated list of dynamic programming problems: conceptual patterns first, then bitmask DP, digit DP, meet-in-the-middle, and LeetCode and Codeforces practice.

Post 14 of 143 min readDSA

On this page

This is the sheet I recommend for learning dynamic programming (DP). It starts with the classic patterns, moves on to advanced techniques, and ends with practice problems to test yourself.

If you complete this sheet, you will be able to solve even tough DP problems on Codeforces, and you will never fear a DP problem again.

Solve it in order. Within each group, the problems build on each other, so try each one on your own before looking at a solution.

1.Conceptual problems

These cover the core DP patterns. Most DP problems you will meet are a variation of one of them.

Knapsack

Grid paths

Longest increasing subsequence

Longest common subsequence

Counting

Buy and sell stock

Matrix chain multiplication

2.CSES problem set

After the conceptual problems, solve every DP problem in the CSES problem set (opens in a new tab). You can check your approach against my CSES DP solutions (opens in a new tab).

3.Bitmask DP

4.Digit DP

5.Meet-in-the-middle

6.Practice problems

Once you know the patterns, use these to test yourself. Nobody tells you which pattern a problem needs, so spotting it is part of the practice.

LeetCode medium

LeetCode hard

Competitive programming

If you want to know how to start competitive programming, read the roadmap from newbie to expert on Codeforces.

↑↓ to move↵ to openesc to close