You are viewing a single comment's thread. Return to all comments →
Guys, if you look for a clear understanding of the solution, I read a pretty clear comment down the road that clarified my mind.
Basically, when you add value from a to b you just need to know that it goes up from k and goes down of k after.
What this algo does is to register the slopes only, so we just need 2 entry, with O(1) complexity.
We just need to know that we are upping from k at the beginning and decreasing at the end.
Finally, the maximum would be...
The addition of all the slopes, that is why it's max(sum) of the tables, because the tables itself registers the slopes
Thanks a lot!!That really helped!
Can you explain the concept of just adding add subtracting at a particular index? I mean how have we arrived to this logic?
I didnt well understand that what will happen if b+1 is out of array bounds?
it can't be out of bounds, it saids that b>n in the problem statement.
if b+1 > n then the the addition of k from position a will continue till the last element of the array.
Jesus christ, it all makes sense now after that graph lol, I kept wondering what drug these people were taking to arrive at this conclusion.
can you explain ? :)