What should I look after to see the changing states, or is the problem of 1D/2D dp? How should I approach the problem?
How do I know if the problem is of 2D DP or 1D DP?
@raghav6 If a problem is dependent on 1 variable/parameter, its a 1D dp problem, similarly in case of 2 variables its 2D dp problem. The best way to approach is to first think about the top-down/recursive solution. If you get a recursive solution, you will clearly know how many dependent variables are there. These are those variables or the parameters whose value changes in each recursive calls. If there is one such variable then it is a 1D dp problem. If there are two such variables then it is a 2D dp problem. Once you get the top down approach it would be easier to think in the bottom up way.
Refer this if you did not understand well.
Hope this helps
2 Likes