Back to problems

Interval List Intersections

Algorithm · Uber · Medium

You receive two collections of closed ranges, firstList and secondList. Both collections are ordered by their starting values, and no two ranges in a single collection overlap. Produce every range shared by the two collections. For ranges [a, b] and [c, d], their common portion is [max(a, c), min(b, d)] provided that max(a, c) <= min(b, d). Follow-up note: When both collections cannot be loaded into memory at once, apply the same two-pointer approach while consuming them…

Checking your access…