Skip to content

Dynamic Programming
Problems and Patterns

CodeStory tags 314 problems as Dynamic Programming, and 106 of the 200 shown are Medium. Write the recursion first, then solve the ten most asked.

Your free account starts with 100 AI credits, and 100 more arrive every month.

How the Dynamic Programming Pattern Works

CodeStory covers the tell, the memo mechanism and the missing state mistake.

Spot the tell. Your problem asks for a maximum or minimum, a count, or whether a goal is possible, and every choice changes what is left. Study CodeStory's Dynamic Programming guide before you code.

Learn the mechanism. Write the recursion first by naming the smallest version and the choice the current step makes. Then stop solving one call twice, either by remembering answers in a map or by filling a table from the smallest case up. Watch the 0/1 knapsack visualiser and the longest common subsequence visualiser fill that table, and practise the recursion in CodeStory's recursion problems.

Avoid the mistake. Leaving a variable out of the state breaks the answer. When two paths reach the same state and need different answers, add a dimension to the state.

Most Asked Dynamic Programming Problems

CodeStory ranks these by how many companies set them.

  1. Binary Tree CamerasHard8 companies
  2. Valid Parenthesis StringMedium5 companies
  3. Count All Valid Pickup and Delivery OptionsHard2 companies
  4. Arithmetic Slices II - SubsequenceHard2 companies
  5. Count Strictly Increasing SubarraysMedium2 companies
  6. House Robber IVMedium2 companies
  7. Difference Between Maximum and Minimum Price SumHard2 companies
  8. Number of Ways to Form a Target String Given a DictionaryHard2 companies
  9. Construct the Longest New StringMedium2 companies
  10. Maximize the Number of Partitions After OperationsHard2 companies

DP Problems FAQs

Start free with no card, or ask a mentor on a free call.

Start Practising DP
How do I know a problem is a DP problem?

CodeStory looks for one sign. Your problem asks for a maximum or minimum, a count, or whether a goal is possible, and every choice changes what is left.

How many DP problems should I solve?

CodeStory suggests ten to fifteen across the levels, which is enough to stop needing the hint. CodeStory tags 314 problems and shows 200 in full, split 9 Easy, 106 Medium and 85 Hard, so expect few Easy ones.

Which mistake costs the most in DP problems?

Missing a variable in the state costs the most. When two paths reach the same state and need different answers, the state needs another dimension.

Should I use memoization or a table for DP?

Memoization keeps your recursion and stores answers in a map, so your code mirrors the problem. Filling a table from the smallest case up avoids deep recursion. Choose memoization to find the states, then switch to a table once they are clear.

Is practising by pattern better than a problem sheet?

Yes. Sheets list problems with no link between them, while CodeStory's patterns show why they sit together, and that carries over to problems you have not seen. CodeStory files every problem under its pattern.

Which DP problems do companies ask most?

Binary Tree Cameras leads, asked at 8 companies in CodeStory's catalogue. Valid Parenthesis String follows at 5 companies.

Is DP practice free to start?

Yes. CodeStory needs no card, gives you 100 AI credits at signup and adds 100 more every month.

Want Guided DP Practice? Get a Free Callback

Tell CodeStory your target company, and a mentor builds your plan.

  1. 1CodeStory checks your level, from first recursion to hard states.
  2. 2CodeStory explains online and campus batches, with timings that fit your week.
  3. 3You decide. No pressure, no payment on the call.

Get a Free Callback

I am a
I want to learn

CodeStory dials your number only for this callback.