So if i form some dp[i] which will store max pssoible money collected for selling rod of length i?
now dp0=0
dp1=arr1
now for dp2 i have 2 options by selling 1+1 piece and by selling directly 2nd piece
Like this if i=4 then there will be many options like
selling 4 pieces of 1
3 and 1
2 and 2
so how to keep track of so many ways and price?
Using a dp approach
dp[i] will store the max money u can get from rod of ith rod
Now assume u have to calculate dp[i+1] then make all possible cuts and stroe the maximum in it
that is if u make cut of 1 then dp[1]+dp[i] if u make cut of 2 then dp[2]+dp[i-1] and so on .
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.