Mid/Senior

Meeting Rooms II

Given an array intervals where intervals[i] = [start_i, end_i] represents the start and end times of a meeting, determine the minimum number of conference rooms required so that all meetings can take place.

Return the minimum number of rooms needed to schedule every meeting without overlap in the same room.

Example 1
0-----------------------------------------------------------30
          5---------10
                              15--------20
Inputintervals = [[0,30],[5,10],[15,20]]
Output2
The meeting from 0 to 30 overlaps with both other meetings, so at least 2 rooms are required.
Example 2
          7-----10
2---4
Inputintervals = [[7,10],[2,4]]
Output1
The two meetings do not overlap, so they can use the same room.

Constraints

  • 1 <= intervals.length <= 10^4
  • 0 <= start_i < end_i <= 10^6

Asked at 42 companies

Practice questions like this out loud in a mock coding interview with a live AI interviewer. First one free.

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, what to keep, what's wrong, and the complexity of your solution.

Sign in to evaluate