Back to problems

Handle Intervals When Input Is Not Sorted

Algorithm · Snowflake · Medium

Problem: Interval Processing — Starting Positions May Be Unordered You receive an array of intervals named intervals; every entry has the form [l, r], where l 2 [4,7] lies within [3,9], while [2,5] does not, so two intervals survive. [[2,6],[3,5]] -> 1 The second interval is entirely contained by the first one. [[1,11],[6,14]] -> 2 Neither interval fully includes the other. [[2,3],[2,6],[4,6]] -> 1 Both [2,3] and [4,6] are covered by [2,6]. [[2,2],[2,4],[4,4],[1,5]] -> 1…

Checking your access…