Meeting Rooms II
You are given a list of meetings in any order, where intervals[i] = [start, end]. Each meeting needs a room from time start until time end. A room that is freed at time t can be used straight away by a meeting starting at time t.
Return the minimum number of rooms needed so that every meeting has a room for its whole duration.
Constraints
0 <= intervals.length <= 10^40 <= start < end <= 10^6
Examples
Example 1
Input: intervals = [[9,12],[10,11],[11,13],[14,15]] Output: 2
From 10 to 11, [9, 12] and [10, 11] run together. At 11, [10, 11] ends just as [11, 13] starts, so that room is reused. Never more than two meetings run at once.
Example 2
Input: intervals = [[2,4],[7,10]] Output: 1
The meetings never overlap, so one room is enough.
Example 3
Input: intervals = [[1,10],[2,9],[3,8],[4,7]] Output: 4
At time 4 all four meetings are running, so each needs its own room.
JavaScript you'll use: Sorting and comparators Heaps and priority queues
/**
* @param {number[][]} intervals
* @return {number}
*/
function minMeetingRooms(intervals) {
}
Ctrl/⌘ + ' runs the examples, Ctrl/⌘ + Enter submits. Use console.log freely: output shows under Console. In the editor, press Esc then Tab to move focus out.