0 day streak

Intervals

Interval problems deal with ranges that have a start and an end, like meetings on a calendar, booked hotel nights or time spans in a log. Typical questions are whether any overlap, how to merge overlapping ones, or the most that are active at once. The standard approach is to sort first, either intervals by start time or all start and end points together, and then make one pass. A sweep line moves across time, adding one at each start and subtracting one at each end, so the running count tells you how many intervals are active at every moment. For “how many meeting rooms do we need?”, the peak of that count is the answer.

In this lesson: A sweep line moves across a timeline with an “active meetings” graph.