Meeting Rooms II
Medium · Intervals · Array · Heap · Sorting · Sweep Line
Problem
Given meeting intervals [start, end], return the minimum number of rooms needed so that no two meetings overlap in the same room.
A meeting ending exactly when another begins does not conflict.
Examples
Input: intervals = [[0,30],[5,10],[15,20]] Output: 2
[0,30] overlaps both others, which do not overlap each other.
Input: intervals = [[7,10],[2,4]] Output: 1
They do not overlap.
Constraints
- 0 <= len(intervals) <= 10^4
- 0 <= start < end <= 10^6
Approaches
- Min-heap of end times — time O(n log n), space O(n)
Related problems
Start free on Cariara · Coding problems · System design studio