Sir what is the error?

@mayank10 Your bases cases were wrong.
have a look at the correct base cases.


for given constraints you have to come up with a 1D Dp approach.
I have corrected it. https://ide.codingblocks.com/s/206616

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.

what is wrong with the code

I have little idea of java
u could refer to the below C++ code
u need to use Long as datatype and put value in Hashmap

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.