Meeting Rooms II
Medium
Array
Two Pointers
Greedy
Sorting
Heap (Priority Queue)
Intervals
Given an array of meeting time intervals `intervals` where `intervals[i] = [startᵢ, endᵢ]`, return *the minimum number of conference rooms required*.
Example 1
Input: intervals = [[0,30],[5,10],[15,20]]
Output: 2
Example 2
Input: intervals = [[7,10],[2,4]]
Output: 1

Constraints

  • 1 <= intervals.length <= 10⁴
  • 0 <= startᵢ < endᵢ <= 10⁶
Time Complexity
O(n log n)
Space Complexity
O(n)
14
Case 1
Input: [[0,30],[5,10],[15,20]]
Expected: 2
Case 2
Input: [[7,10],[2,4]]
Expected: 1
Case 3
Input: [[1,5],[8,9],[8,9]]
Expected: 2