You are viewing a single comment's thread. Return to all comments →
I'm still trying to figure it out myself. But if you graph result after doing the operations, you would see some rise and fall in the graph.
It looks like his solution tracks the differences between each data point. It went up by x, down by y, remained the same...etc. And his solutions finds the highest increase.
1 2 100
2 5 100
3 4 100
After doing the operations you get [100, 200, 200, 200, 100]
His solutions final array is [0, 100, 100, 0, 0, -100]
Meaning starting at 0 the graph went up by 100, went up by 100 again, remained the same, then went back down by 100.
So the highest point is 200, the solution.
you add up all the numbers > 0 in the final list, which is 100 + 100 = 200
I have created a video tutorial for you and uploaded the same on youtube.
Here is the video tutorial for my solution O(n+m) complexity.
Would really appreciate your feedback like, dislike , comment etc. on my video.