Help me out in this


Hello @shivammishra20121999 what is the problem that you are facing?

@tusharaggarwal272 hey i am getting wrong answer

@tusharaggarwal272 just have a look

@shivammishra20121999 okay wait.

@tusharaggarwal272 are u there bro?

please wait i have to check eveything.

@tusharaggarwal272 can i explain my logic or it is fine for you ?

hello @shivammishra20121999 see this :


in my times also i was also suggested not to declare anything as global while doing dynamic programming.

Happy Learning!!

@tusharaggarwal272 what is the error ?

your code is perfetly fine and your logic too but just declaring the dp array as global was wrong.

@tusharaggarwal272 okay

Hello @shivammishra20121999 if you feel that your doubt is cleared you can now mark this doubt as resolved.
Happy Learning!!

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.