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.
It took me a minute to understand your approach.
Basically your solution takes into account the fact the sections of the array where queries make the most additions will influence the output the most. There is no need to add a query to all elements in its range. It just needs to be added once at the start of its range. The array maximum value can be found among the elements where most of the queries made an addition or at an element with the largest added value.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Array Manipulation
You are viewing a single comment's thread. Return to all comments →
It took me a minute to understand your approach. Basically your solution takes into account the fact the sections of the array where queries make the most additions will influence the output the most. There is no need to add a query to all elements in its range. It just needs to be added once at the start of its range. The array maximum value can be found among the elements where most of the queries made an addition or at an element with the largest added value.