Meeting Rooms II

Hard~25 min

Given an array of meeting time intervals intervals where intervals[i] = [start_i, end_i], return the minimum number of conference rooms required.

Examples

Example 1
Input: intervals = [[0,30],[5,10],[15,20]]
Output: 2
Explanation: Meeting [0,30] overlaps with both [5,10] and [15,20], but [5,10] and [15,20] don't overlap with each other. So we need 2 rooms: one for [0,30] and one shared by [5,10] then [15,20].
Example 2
Input: intervals = [[7,10],[2,4]]
Output: 1
Explanation: The two meetings don't overlap, so only 1 room is needed.

Constraints

  • 1 <= intervals.length <= 10^4
  • 0 <= start_i < end_i <= 10^6
  • Expected time complexity: O(n log n)
Code
Ctrl+EnterRun|Ctrl+⇧+EnterSubmit
Output

Run your code to see results

Use Cmd+Enter to run