Tilling problem-2


why does this code not work …correct it i want to solve it using top down dp only…

@S19LPPP0202 you have not made a base case for cases where n > 0 && n < m
You can refer to this code https://ide.codingblocks.com/s/254355

how do u decide all base cases??explain in detail plz…
also tell how to decide size of dp array …when declaring it globally??

@S19LPPP0202 when declaring a global DP array, you can make the size according to the constraints given in the question. Although it is better to make a dynamic array according to the input itself. Dynamic array will be declared in heap memory so you dont need to worry about stack memory there also.
To decide all the base cases, just see which cases cannot be solved by calling a smaller problem, and that should be a base case.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.