i have started doing questions on dynamic programming some time ago and how i can do very basic dp problems only and that too with recursive approach but when i see their editorials or other submittion most of the people use iterative approach and which never comes in my mind . i can only think a dp problem recursively so please anyone tell me, what can be the reason , is i am new or it’s depend on the way our mind think about the problem?
I too prefer solving DP problems recursively. It works most of the time, but recursive solutions TLE in some problems, so you’ll be left with no choice but to code an iterative version in those problems. An example of such a problem is this.
So what I do is, after solving a DP problem recursively, I try to code it in a bottom-up manner or at least think of how I would code it bottom up.
you can checkout this playlist for iterative dp problem tutorials.