We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.

We can try to understand this logic like we imagine Supermario walking on a N width horiz line. a and b is the
point on the line, k is the mushroom Mario always like to eat.
When Mario go to the point at a,he eat the k size mushroom and become taller,after he have walked through point b,
his height reverse to the origin height before he eat the mushroom.
eg.
1. When Mario is walking to a, he eat a k size mushroom, and become k bigger
2. Then Mario is walking to a', he eat a k' size mush, and become k' bigger, now Mario's height is (k + k')
3. If Mario have walked to b, so he pooped out the mushroom and become k smaller, the only way that he can
become larger is to meet a new (a,b) point and eat a new k size mushroom
4. The rest can be done in the same manner.

What we need to do is tracing the Mario's biggest height when walking through that muliple query's a and b point.

## Array Manipulation

You are viewing a single comment's thread. Return to all comments →

We can try to understand this logic like we imagine Supermario walking on a N width horiz line. a and b is the point on the line, k is the mushroom Mario always like to eat. When Mario go to the point at a,he eat the k size mushroom and become taller,after he have walked through point b, his height reverse to the origin height before he eat the mushroom. eg. 1. When Mario is walking to a, he eat a k size mushroom, and become k bigger 2. Then Mario is walking to a', he eat a k' size mush, and become k' bigger, now Mario's height is (k + k') 3. If Mario have walked to b, so he pooped out the mushroom and become k smaller, the only way that he can become larger is to meet a new (a,b) point and eat a new k size mushroom 4. The rest can be done in the same manner.

Best explanation, thanks.

thanks a lot bro this is best explanation i found of this problem.

This is the best explanation ever. Thank you.

Hi,

I have created a video tutorial for the same on youtube with complete explanation along with code complexity analysis.

Here is the video tutorial for my solution O(n+m) complexity passed all test cases.

https://youtu.be/hDhf04AJIRs

Would really appreciate your feedback like, dislike , comment etc. on my video.