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 -
- Longest Common Subsequence | Introduction & LCS Length
- Longest Common Subsequence | Finding all LCS
- Longest Common Substring problem
- Longest Palindromic Subsequence using Dynamic Programming
- Longest Repeated Subsequence Problem
- Implement Diff Utility
- Shortest Common Supersequence | Introduction & SCS Length
- Shortest Common Supersequence | Finding all SCS
- Longest Increasing Subsequence using Dynamic Programming
- Longest Bitonic Subsequence
- Increasing Subsequence with Maximum Sum
- The Levenshtein distance (Edit distance) problem
- Find size of largest square sub-matrix of 1’s present in given binary matrix
- Matrix Chain Multiplication using Dynamic Programming
- Find the minimum cost to reach last cell of the matrix from its first cell
- Find longest sequence formed by adjacent numbers in the matrix
- Count number of paths in a matrix with given cost to reach destination cell
- 0–1 Knapsack problem
- Maximize the Value of an Expression
- Partition problem | Dynamic Programming Solution
- Subset Sum Problem
- Minimum Sum Partition Problem
- Find all N-digit binary strings without any consecutive 1’s
- Rod Cutting Problem
- Maximum Product Rod Cutting
- Coin change-making problem (unlimited supply of coins)
- Coin Change Problem (Total number of ways to get the denomination of coins)
- Longest Alternating Subsequence Problem
- Count number of times a pattern appears in given string as a subsequence
- Collect maximum points in a matrix by satisfying given constraints
- Count total possible combinations of N-digit numbers in a mobile keypad
- Find Optimal Cost to Construct Binary Search Tree
- Word Break Problem | Dynamic Programming
- Word Break Problem | Using Trie Data Structure
- Total possible solutions to linear equation of k variables
- Wildcard Pattern Matching
- Find Probability that a Person is Alive after Taking N steps on an Island
- Calculate sum of all elements in a sub-matrix in constant time
- Find Maximum Sum Submatrix in a given matrix
- Find Maximum Sum Submatrix present in a given matrix
- Find maximum sum of subsequence with no adjacent elements
- Maximum Subarray Problem (Kadane’s algorithm)
- Single-Source Shortest Paths — Bellman Ford Algorithm
- All-Pairs Shortest Paths — Floyd Warshall Algorithm
- Pots of Gold Game using Dynamic Programming
- Find minimum cuts needed for palindromic partition of a string
- Maximum Length Snake Sequence
- 3-Partition Problem
- Calculate size of the largest plus of 1’s in binary matrix
- Check if given string is interleaving of two other given strings