Interval List Intersections

Medium · Intervals · about 20 minutes

Asked at Meta, Uber, DoorDash, Grab, Swiggy.

firstList and secondList each contain closed intervals, sorted and non-overlapping within their own list. Return, in sorted order, the closed intervals where the two lists overlap, i.e. the stretches covered by an interval from each list.

Related guides