Meeting Rooms II

IF
AlgoAxiomStaff Engineers
JSTS
Medium20 mins

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

Examples

Example 1:

Input: intervals = [[0,30],[5,10],[15,20]]

Output: 2

Explanation: Meeting [0,30] occupies one room the entire time. Meeting [5,10] overlaps with it, requiring a second room. Meeting [15,20] also overlaps with [0,30] but [5,10] has ended, so only 2 rooms are needed at peak.

Example 2:

Input: intervals = [[7,10],[2,4]]

Output: 1

Explanation: The two meetings do not overlap — [2,4] ends before [7,10] starts — so a single room suffices.

Example 3:

Input: intervals = [[0,30],[5,10],[10,15],[15,20]]

Output: 2

Explanation: At most 2 meetings overlap at any point in time. For instance at time 5, meetings [0,30] and [5,10] are both active.

Constraints

  • 1 <= intervals.length <= 10^4
  • 0 <= start_i < end_i <= 10^6
Source: Intervals pattern — AlgoAxiom
JavaScript
Test Case 1
root = [1, 2, 3]
Test Case 2
root = [1, 2, 3, 4, 5]
Idle