I initially solved this as a Segment Tree problem.
There was an error while loading. Please reload this page.