mediumIntervalsPure DSA~24 min
Minimum Meeting Rooms
Given the day's calendar of meeting start/end times, the facilities system must reserve the fewest rooms so that no two overlapping meetings share a room.
Problem
Given an array of intervals where intervals[i] = [start, end], return the minimum number of rooms required to host all meetings without overlap. A meeting that ends exactly when another begins does not overlap.
Input
An array intervals of n pairs (0 ≤ n ≤ 10^4), 0 ≤ start < end ≤ 10^6.
Output
An integer — the minimum number of rooms.
Constraints
- 0 ≤ intervals.length ≤ 10,000
- An end time equal to a start time is not an overlap
- start < end for every interval
Examples
Example 1
Input
[[0,30],[5,10],[15,20]]
Output
2
[0,30] overlaps both others, which themselves don't overlap → 2 rooms.
Example 2
Input
[[7,10],[2,4]]
Output
1
The two meetings are disjoint, so one room suffices.