Meeting Rooms II
Python data engineering interview problem. Difficulty: intermediate. Pattern: Intervals. About 14 minutes. Part of the Pro drill bank.
Minimum number of meeting rooms required. Treat this as a production helper: match the contracted return shape, including empty and duplicate inputs.
A meeting service needs enough rooms for all meetings that overlap. When one meeting ends, its room can be reused by a later meeting. Return the minimum number of rooms needed to hold every interval. A meeting that starts when another ends can use the same room. Write the function min_meeting_rooms(intervals: list) -> int. For [0, 30], [5, 10] and [15, 20], the long meeting overlaps one short meeting at a time, so two rooms are enough. The starter file already has the function name and the harness print lines. Keep them, and fill only the function body.
Requirements
- Count the maximum number of simultaneous meetings.
- Reuse a room when its meeting ends before or at the next start.
- Return the minimum room count as an integer.
Constraints
- Intervals are [start, end] pairs and may be unsorted.
- The return type is int; an empty list needs 0 rooms.
Examples
Input: min_meeting_rooms([[0, 30], [5, 10], [15, 20]]) Output: 2 Peak concurrency is 2.
Topics: lakebench, python, heap, rooms.
More Python interview questions · All interview problems · Learn data engineering
Meeting Rooms II
Interview-style drill: Minimum number of meeting rooms required.
Implement `min_meeting_rooms(intervals: list) -> int`. Example: `[[0, 30], [5, 10], [15, 20]]` → `2`. Keep the harness.