Interval Sweep — definition.
Definition
Sort events by time, sweep a line, maintain an active set for overlap questions.
Complexity
Time O(n log n) for the sort; O(n) for the sweep.
When to use it
- Merge / intersect / count overlapping intervals.
- Meeting-room count and scheduling conflicts.
- Skyline and "maximum concurrent" queries.
Representative scenarios
- Meeting Room Budget — minimum rooms for overlapping meetings.
- Event Merge — collapse overlapping intervals into a minimal set.
- Skyline Silhouette — city skyline from rectangles.
Related patterns
Read the full pattern page: Interval Sweep — template, code, and drills.
Run the free diagnostic.
Ten-minute patterns quiz. No card. Personalized loop starts on the other side.