Skip to main content

Minimum Meeting Rooms Required

medium
IntervalsArraySortingHeapLine SweepIntervals Sweep LineGreedy IntervalTwo Heap
Asked atGoogleAmazonMicrosoftMetaUberBloomberg

Problem Description

You are given a list of meeting time intervals where `bookings[i] = [startI, endI]` (end is exclusive — the room is freed at `endI`). Determine the minimum number of meeting rooms needed to schedule all meetings without any conflicts.

**Example 1:**
```
Input: bookings = [[0,30],[5,10],[15,20]]
Output: 2
Explanation:
At time 5, meetings [0,30] and [5,10] overlap -> need 2 rooms.
```

**Example 2:**
```
Input: bookings = [[7,10],[2,4],[3,8],[9,12],[1,6]]
Output: 3
Explanation:
At time 3, [2,4],[3,8],[1,6] all overlap -> need 3 rooms.
```

Constraints

  • 1 <= bookings.length <= 10^4
  • 0 <= startI < endI <= 10^6

Follow-up

If you also need to output which meetings are assigned to which room, how would you modify your approach?

Hints

Try the problem first. If you get stuck, you can reveal hints one at a time.

Solution

Leaderboard

No entries yet for python.

Be the first — submit an accepted solution.