My issue
it would be better if that is more explained here. because just seeing that dp and we cant get that logic . if that is illustrated as previous subset question it would be great
Learning course: Dynamic programming
Problem Link: Multiple Choice Question Practice Problem in Dynamic programming - CodeChef
@abhiram_nagam
in the previous section it is said that u can cut the ribbons to even lengths and the length of cutout should not exceed L .
so the dp[n] will only depends on even lengths.
Correct Answer:
DP[N] = DP[N-2] + DP[N-4] + DP[N-6] + ... till DP[N-L+1]
Explanation:
That's correct.
DP[N] = DP[N-2] + DP[N-4] + DP[N-6] + ... till DP[N-L+1]
We jump by 2 each time since we need to take only even sized parts. But you have to be careful that N-L+1 doesn't go out of bounds.
yeah bro ! but im new this this DP im trying to learn how to identify those patterns. in the previous question of this learning(subset sum) they explained very well by showing how the subproblems are working. but in this they directly went into writing the DP , so that is why im confused. i need that kind of explanation like taking subproblems and showing how the logic is working . kinda showing the iterations but explaining the meaning. i think u got me !