[important][dp] run error on SUPW

link: https://ide.codingblocks.com/s/206395

When you are initializing dp[0] dp[1] dp[2] then first you have to check whether these exists or not i.e check what if n==0 or n==1 or n==2
Also change the name class from SUPW to Main, it is giving error for that also

tried that also.but still get run time error.
link for latest code: https://ide.codingblocks.com/s/206442

@dhruv.160410116084 Your code is correct but try the Bottom up approach, recursion is causing problem here as in case of a very large number of recursive calls the call stack will overflow. Iterative solution will work fine here.

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.