← All Exercises
Minimum Meeting Rooms with a Heap
intermediatepython
Background
Interval partitioning schedules classrooms, servers, and interview slots, and reduces to counting maximum simultaneous intervals.
Problem
Given meeting intervals, return the minimum number of rooms required so that no two meetings overlap in the same room.
Input
A list of [start, end] intervals where start < end, in arbitrary order.
Output
The minimum room count as an integer; zero for an empty list.
Sample tests
Sample 1
Input: intervals = [[0,30],[5,10],[15,20]]
Expected: 2
Sample 2
Input: intervals = [[7,10],[2,4]]
Expected: 1
Sample 3
Input: intervals = [[1,5],[5,10]]
Expected: 1
Your solution
Learning objective
Combine interval sorting with a min-heap of end times to compute the peak number of simultaneous meetings.