Practice Discrete Math

Algorithms / Interval Overlap Meeting Rooms

Least You Need to Know: Interval Overlap, Meeting Rooms, and End-Time Heaps

Some interval problems are not about choosing one compatible subset. Instead they ask for the **maximum number of overlapping intervals** at any moment, or equivalently the minimum number of rooms needed to host them all. A min-heap of end times tracks how many intervals are active right now.

The least you need to know

Key notation

[s, f) interval starting at s and ending at f
active interval an interval whose end time has not yet passed
min-heap of end times earliest finishing active interval at the root

Tiny worked example

  • Sort meetings by start time.
  • Push the first meeting's end time into a min-heap.
  • For each new meeting, compare its start to the smallest current end time.
  • If that room is free, pop it; then push the new end time.
  • The maximum heap size seen is the number of rooms needed.

Common mistakes

How to recognize this kind of problem

Start practice