Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...]
(si < ei), find the minimum number of conference rooms required.
Example 1:
Input: [[0, 30],[5, 10],[15, 20]]
Output: 2
Example 2:
Input: [[7,10],[2,4]]
Output: 1
- We need a extra meeting room if there is any overlap between meetings.
[[1, 3], [2, 4]]
1, 2, 3, 4, 5, 6, 7, 8
|-----| // Room 1
|-----| // Room 2
- But we can reuse a meeting room if the two meetings are not overlapping so that we can have the minimum number of meeting rooms.
[[1, 3], [2, 4], [5, 7]]
1, 2, 3, 4, 5, 6, 7, 8
|-----| |-----| // Room 1
|-----| // Room 2
NOTE This is a classic problem of finding the maximum number of overlapping intervals at any point of time, and it's a prenium problem on LeetCode, so we move the key notes to 2406. Divide Intervals Into Minimum Number of Groups, the ideas and implementations are the same.