Dynamic Programming Interview Questions

A 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 given by Jonathan Paulson on Quora on concept of Dynamic Programming to a kid.

*writes down “1+1+1+1+1+1+1+1 =” on a sheet of paper*
“What’s that equal to?”
*counting* “Eight!”
*writes down another “1+” on the left*
“What about that?”
*quickly* “Nine!”
“How’d you know it was nine so fast?”
“You just added one more”
“So you didn’t need to recount because you remembered there were eight! Dynamic
Programming is just a fancy way to say ‘remembering stuff to save time later'”

Below is the list of commonly asked interview questions that can be solved using Dynamic programming –


  1. Longest Common Subsequence | Introduction & LCS Length
  2. Longest Common Subsequence | Space optimized version
  3. Longest Common Subsequence of K-sequences
  4. Longest Common Subsequence | Finding all LCS
  5. Longest Common Substring problem
  6. Longest Palindromic Subsequence using Dynamic Programming
  7. Longest Repeated Subsequence problem
  8. Implement Diff Utility
  9. Shortest Common Supersequence | Introduction & SCS Length
  10. Shortest Common Supersequence | Finding all SCS
  11. Shortest Common Supersequence | Using LCS
  12. Longest Increasing Subsequence using Dynamic Programming
  13. Longest Bitonic Subsequence
  14. Increasing Subsequence with Maximum Sum
  15. The Levenshtein distance (Edit distance) problem
  16. Find size of largest square sub-matrix of 1’s present in given binary matrix
  17. Matrix Chain Multiplication
  18. Find the minimum cost to reach last cell of the matrix from its first cell
  19. Find longest sequence formed by adjacent numbers in the matrix
  20. Count number of paths in a matrix with given cost to reach destination cell
  21. 0-1 Knapsack problem
  22. Maximize value of the expression
  23. Partition problem
  24. Subset sum problem
  25. Minimum Sum Partition problem
  26. Find all N-digit binary strings without any consecutive 1’s
  27. Rod Cutting
  28. Maximum Product Rod Cutting
  29. Coin change-making problem (unlimited supply of coins)
  30. Coin Change Problem – Find total number of ways to get the denomination of coins
  31. Longest alternating subsequence
  32. Count number of times a pattern appears in given string as a subsequence
  33. Collect maximum points in a matrix by satisfying given constraints
  34. Count total possible combinations of N-digit numbers in a mobile keypad
  35. Find optimal cost to construct binary search tree
  36. Word Break Problem
  37. Wildcard Pattern Matching
  38. Find probability that a person is alive after taking N steps on the island
  39. Calculate sum of all elements in a sub-matrix in constant time
  40. Find maximum sum K x K sub-matrix in a given M x N matrix
  41. Find maximum sum submatrix present in a given matrix
  42. Find maximum sum of subsequence with no adjacent elements
  43. Maximum subarray problem (Kadane’s algorithm)
  44. Single-Source Shortest Paths – Bellman Ford Algorithm
  45. All-Pairs Shortest Paths – Floyd Warshall Algorithm


Thank you all for your valuable time and being with us. 🙂