I am not getting the part where Sir identifies :
dp[r]=(x[i]*(-y[r])+dp[i]) + y[r]*x[r]-ar[r].sec
in the first part of this expression x[i] is variable of the line and -y[r] is the slope and it depends on ‘r’ but there are still other terms that depends on ‘r’ then why did he take this term only for the slope? he did the same thing in the bear and bowling question, can u pls explain this clearly?
Convex hull trick dp (fairnut and rectangles)
Hey @aman2382000
You just need to look at the equation in terms of a linear equation.
A linear equation is of the form : y = m*x+c
The equation we have : dp[r]=(dp[i]+x[i]*(-y[r])) + (y[r]*x[r]-ar[r].sec)
If you try to see the similarity here,
{ y = dp[r] }
{ m = -y[r] }
{ x = x[i], dp[i] }
{ c = y[r]*x[r]-ar[r].sec }
The slope is basically the term multiplied to the variable in a linear equation which is -y[r] in our case
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.