LeetCode page
I originally solved this as a Segment Tree problem.
This turned out to be much simpler and faster using a priority queue.
There was an error while loading. Please reload this page.