Editorial for SAC '22 Code Challenge 5 P4 - Querying Intervals


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

Author: maxcruickshanks

Realize that all the intervals can be merged to allow for easier checking.

Merge the intervals through some data structure (either built-in or some user-defined one) and then, for each query, binary search for the first interval that has an endpoint after this and check that it covers the entire range of [Li,Ri].

Time Complexity: O(NlogN+QlogN)


Comments

There are no comments at the moment.