Didn't understood line 31 in bottomup approach

In bottom up approach what are we exactly doing in line no 31 . arr[j] + dp[i-j] . how are we breaking down the problem . suppose n = 3 so, we need to get ans from n=0 , n=1 , n=2. and the add the arr[3] in it and find the maximum.

why are we not using arr[i]+dp[i-j] .

hello @sinhadivyam19
let say we have rod of length i .
and we have cut length j from that rod so how we will represent the total cost.
it will be a[j] -> profit from j length rod
dp[i-j] -> profit from remaining rod.
so in total it will be a[j] + dp[i-j]

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.