Facebook Pixel

Meeting Rooms II

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

Input

  • intervals: an array of meeting time intervals where intervals[i] = [starti, endi]

Output

the minimum number of conference rooms required

Examples

Example 1:

Input:

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

Output: 2

Explanation:

We need two meeting rooms: Room 1: [0,30] Room 2: [5,10], [15,20]

Example 2:

Input:

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

Output: 1

Explanation:

We need one meeting room: Room 1: [2,4], [7,10]

Example 3:

Input:

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

Output: 3

Explanation:

We need three meeting rooms: Room 1: [0,30] Room 2: [5,10], [15,20] Room 3: [5,15]

Constraints

  • 1 <= intervals.length <= 10^4
  • 0 <= starti < endi <= 10^6

Try it yourself

Invest in Yourself
Your new job is waiting. 83% of people that complete the program get a job offer. Unlock unlimited access to all content and features.
Go Pro