Meeting Rooms II
Part of Practice: Rooms & Queries
You are given a list of meeting time intervals, each a pair [start, end]. Every meeting must happen in some room, and a room holds one meeting at a time. Return the minimum number of rooms needed to host the entire schedule. A meeting that starts exactly when another ends can reuse the same room.
Constraints that matter: up to 100,000 meetings. The answer equals the maximum number of meetings running simultaneously at any instant — the challenge is computing that peak efficiently.
Examples
- Input:
- intervals = [[0,30],[5,10],[15,20]]
- Output:
- 2
[0,30] occupies one room the whole time. [5,10] and [15,20] overlap it but not each other, so they share a second room.
- Input:
- intervals = [[7,10],[2,4]]
- Output:
- 1
The meetings do not overlap; one room hosts both.
- Input:
- intervals = [[1,5],[5,9],[5,12]]
- Output:
- 2
At time 5, [1,5] ends as [5,9] and [5,12] begin. The freed room is reused, so two rooms cover the peak of two simultaneous meetings.
Hints
One at a time — struggle first, peek second.
Your thinking space — verify on LeetCode, then mark it.