Dynamic Programming Types and Patterns

How to solve different types of DP problems asked in coding interviews

Ashutosh Kumar
5 min readDec 3, 2020
Photo by David White on Unsplash

Dynamic Programming is the most asked question in coding interviews due to three main reasons:

  • It is hard to solve
  • Difficult to find the pattern and the right approach to solve the problem.
  • There are various types of Dynamic Programming Problems and different approaches to all those types.

In this article, I would be discussing the different types of Dynamic Programming problems, how to identify the patterns, and solve them with the right approach.

After solving more than fifty problems in Leetcode on Dynamic Programming I started to see some patterns, where few problems were similar to one another. The solution to those problems had the same approach.

For example, after solving the knapsack problem, I found it easy to solve the coin change problem as the solution was similar to that of the knapsack problem with the same approach.

Often the problems asked in interviews are the variations to these problems. So all we need to do is practice these different types of problems and when a problem with a similar pattern is given we need to apply the same approach to find the solution.

--

--

Ashutosh Kumar
Ashutosh Kumar

Written by Ashutosh Kumar

Works at Tech. Writes about Life, Tech, Career, Travel, and Money. Here to Share my Learnings and Experiences with you.

Responses (3)