Printing 1 for each case, i don't know the problem is with my code or with cb ide

hello @Parmeet-Kalsi-1631789033630118

image

this not a recursive code , so dont use return here.

first finish the execution of the for loop and then return the dp value

also ur dp states are not correct .

follow this->

Can it be done using 2d dp

no . . . . . . . . … . … . , we have k as well, which will add 1 more state in ur dp thats why 3d dp

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.