Meeting Rooms II
Given an array of meeting time intervals [start, end], find the minimum number of conference rooms required.
A meeting occupies a room from start until end. A meeting that ends at time frees its room for a meeting that starts at exactly .
min_meeting_rooms(intervals) receives intervals as a list of [start, end] pairs and returns an integer. The example input 0,30;5,10;15,20 is shorthand for [[0, 30], [5, 10], [15, 20]].
Example
0,30;5,10;15,20
2
- Input: three meetings, each a pair (start, end): , and .
- The meeting holds one room from to .
- From to a second meeting is running alongside it, so rooms are busy. At that meeting ends and its room is free again.
- From to only one meeting runs. From to the third meeting needs a second room, and it can take the one freed at .
- Output:
2, the largest number of meetings in progress at any single moment. One room would clash at . - Notice the answer is not the meeting count (): the two short meetings never overlap, so they share a room. A meeting ending at time also frees its room for one starting at exactly , so and need just room.
Constraints
- 1 <= len(intervals) <= 10^4
- 0 <= start < end <= 10^6