AlgoScope

Minimum Platforms

Arrivals and departures sorted as one event list. The peak number open is the platforms needed.

Greedy, algorithm, intermediate
3 rooms needed.012345678910abcdefaaabbbccccdddeeeefff

Intervals and Greedy Choices: How many rooms

Result, step 14 of 14

3 rooms. At the peak 3 meetings overlapped, so fewer rooms cannot work, and the sweep never needs more than the peak. Sorting the 2n endpoints dominates: O(n log n).

How intervals and greedy choices works

Cost

Best
O(n log n)
Average
O(n log n)
Worst
O(n log n)
Space
O(1)

A variant of

Taught by the same lesson

Intervals and Greedy Choices covers these too, in the same run.