Top 50 Dynamic Programming Practice Problems

Dynamic Programming is a method for solving a complex problem by breaking it down into a collection of simpler subproblems, solving each of those subproblems just once, and storing their solutions using a memory-based data structure (array, map,etc). Each of the subproblem solutions is indexed in some way, typically based on the values of its input parameters, so as to facilitate its lookup. So the next time the same subproblem occurs, instead of recomputing its solution, one simply looks up the previously computed solution, thereby saving computation time. This technique of storing solutions to subproblems instead of recomputing them is called memoization.

Here’s brilliant explanation on concept of Dynamic Programming on Quora — Jonathan Paulson’s answer to How should I explain dynamic programming to a 4-year-old?

Please find below top 50 common data structure problems that can be solved using Dynamic programming -

  1. Longest Common Subsequence | Introduction & LCS Length
  2. Longest Common Subsequence | Finding all LCS — Techie Delight
  3. Longest Common Substring problem — Techie Delight
  4. Longest Palindromic Subsequence using Dynamic Programming
  5. Longest Repeated Subsequence Problem — Techie Delight
  6. Implement Diff Utility — Techie Delight
  7. Shortest Common Supersequence | Introduction & SCS Length
  8. Shortest Common Supersequence | Finding all SCS — Techie Delight
  9. Longest Increasing Subsequence using Dynamic Programming — Techie Delight
  10. Longest Bitonic Subsequence — Techie Delight
  11. Increasing Subsequence with Maximum Sum — Techie Delight
  12. The Levenshtein distance (Edit distance) problem — Techie Delight
  13. Find size of largest square sub-matrix of 1’s present in given binary matrix — Techie Delight
  14. Matrix Chain Multiplication using Dynamic Programming
  15. Find the minimum cost to reach last cell of the matrix from its first cell — Techie Delight
  16. Find longest sequence formed by adjacent numbers in the matrix — Techie Delight
  17. Count number of paths in a matrix with given cost to reach destination cell
  18. 0–1 Knapsack problem — Techie Delight
  19. Maximize the Value of an Expression — Techie Delight
  20. Partition problem | Dynamic Programming Solution — Techie Delight
  21. Subset Sum Problem — Techie Delight
  22. Minimum Sum Partition Problem — Techie Delight
  23. Find all N-digit binary strings without any consecutive 1’s — Techie Delight
  24. Rod Cutting Problem — Techie Delight
  25. Maximum Product Rod Cutting — Techie Delight
  26. Coin change-making problem (unlimited supply of coins) — Techie Delight
  27. Coin Change Problem (Total number of ways to get the denomination of coins) — Techie Delight
  28. Longest Alternating Subsequence Problem — Techie Delight
  29. Count number of times a pattern appears in given string as a subsequence
  30. Collect maximum points in a matrix by satisfying given constraints — Techie Delight
  31. Count total possible combinations of N-digit numbers in a mobile keypad — Techie Delight
  32. Find Optimal Cost to Construct Binary Search Tree — Techie Delight
  33. Word Break Problem | Dynamic Programming — Techie Delight
  34. Word Break Problem | Using Trie Data Structure — Techie Delight
  35. Total possible solutions to linear equation of k variables — Techie Delight
  36. Wildcard Pattern Matching — Techie Delight
  37. Find Probability that a Person is Alive after Taking N steps on an Island
  38. Calculate sum of all elements in a sub-matrix in constant time — Techie Delight
  39. Find Maximum Sum Submatrix in a given matrix — Techie Delight
  40. Find Maximum Sum Submatrix present in a given matrix — Techie Delight
  41. Find maximum sum of subsequence with no adjacent elements — Techie Delight
  42. Maximum Subarray Problem (Kadane’s algorithm) — Techie Delight
  43. Single-Source Shortest Paths — Bellman Ford Algorithm — Techie Delight
  44. All-Pairs Shortest Paths — Floyd Warshall Algorithm — Techie Delight
  45. Pots of Gold Game using Dynamic Programming — Techie Delight
  46. Find minimum cuts needed for palindromic partition of a string
  47. Maximum Length Snake Sequence — Techie Delight
  48. 3-Partition Problem — Techie Delight
  49. Calculate size of the largest plus of 1’s in binary matrix — Techie Delight
  50. Check if given string is interleaving of two other given strings