Test case failing

dp.resize(size+1,0);
suppose size of dp is 20 initially and now using resize you make it 50
but problem is that make 0 only to new memory not for the already existing memory

Modified Code

this is modified code
but it will give TLE
for that your have to use Bottom up dp

I modified it to bottom up. One test case still fails, not sure why.

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.