Wrong recurrence relation written

it dp[n]=sum(i=1 to k) dp[n-i] not dp[i-k].

hello @touqeer11
in bottom u approach we compute answer for all the states (i,e 1 to n )
so dp[i]= summation dp[i-j] where j goes from 1 to k ,for each value of i .

so the recurrence is correct.

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.