Merge Intervals
Overlapping ranges.
5 pages
- Pattern 05: Merge IntervalsPattern guide
Sort first, then a single linear sweep. Sort by start to merge; sort by end for greedy "max non-overlapping"; use a min-heap of end times for room/resource…
- LC 57Insert Interval (LC 57)Medium
Insert a new interval into a sorted, non-overlapping list by scanning in three phases—before, merge, after—without full resorting.
- LC 252Meeting Rooms (LC 252)Easy
After sorting by start time, a person can attend all meetings iff every meeting starts on or after the previous meeting’s end (no overlap).
- LC 253Meeting Rooms II (LC 253)Medium
The minimum number of conference rooms equals the maximum number of meetings happening at the same time; track “active” meetings via a min-heap of end times…
- LC 986Interval List Intersections (LC 986)Medium
With two sorted, disjoint lists, walk both with two pointers; the intersection of current intervals is [max(starts), min(ends)] when max(starts) <=…