39. Meeting Rooms II — Resource Count
Assign every meeting to a room so that no two meetings occupying the same room overlap. Return the smallest number of rooms that makes a complete assignment possible.
Rooms are interchangeable, and a room can be reused as soon as its previous meeting ends. Simultaneous demand determines how many rooms are needed.
Example 1
Input
[[0,30],[5,10],[15,20]]
Output
2
Explanation: The long meeting overlaps each short one, but the two short meetings can reuse one room.
Example 2
Input
[[0,3],[0,3],[3,5],[3,5]]
Output
2
Explanation: Both rooms release at three before the two new meetings begin.
Constraints
0 <= meetings.length <= 105meetings[i].length == 2-231 <= start < end <= 231 - 1
Hints
Hint 1
What quantity lower-bounds the number of rooms at an instant?
Hint 2
Which old meetings have ended before the next arrival?
Hint 3
Expire all end≤start, add the new end, and record peak heap size.
Submissions
Your recent submissions for this problem.
Checking sign-in…
Discussion
Ask a question or share an approach. Posts are public; avoid personal information and mark solution spoilers clearly.
No discussion yet. Start the conversation with a question about this problem.
Checking sign-in…
Run your code to check the sample cases, or submit it to check the full validation suite.
A released short meeting lets a room be reused
[[0,30],[5,10],[15,20],[30,40]]
2