Minimum Number of Rooms to Schedule Overlapping Meetings

Quick Overview

Given meetings as half-open time intervals, find the smallest number of rooms needed so that no two meetings sharing a room overlap. Tests interval reasoning, correct handling of back-to-back meetings and duplicates, and an efficient solution for up to 100,000 meetings.

Minimum Number of Rooms to Schedule Overlapping Meetings

Company: Google

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

You are given a list of meetings, where `meetings[i] = [start, end]` means meeting `i` occupies the half-open time interval `[start, end)`. Every meeting must be held in one room for its whole interval, and two meetings can share a room only if their intervals do not overlap. Return the minimum number of rooms needed to hold all the meetings. ### Function Signature ```python def min_meeting_rooms(meetings: list[list[int]]) -> int: ``` ### Rules - Intervals are half-open: a meeting that ends at time `t` and a meeting that starts at time `t` do not overlap and may use the same room. - Meetings are given in no particular order. Identical intervals are separate meetings, and each needs its own room. - An empty list needs `0` rooms. ### Constraints - `0 <= len(meetings) <= 10^5` - Each `meetings[i]` contains exactly two integers with `0 <= start < end <= 10^9`. - The result is an integer from `0` to `len(meetings)` inclusive. ### Examples **Example 1** - Input: `meetings = [[1, 10], [2, 6], [7, 12]]` - Output: `2` - Explanation: `[1, 10)` overlaps both other meetings, so it needs a room of its own. `[2, 6)` ends before `[7, 12)` starts, so those two can share a second room. **Example 2** - Input: `meetings = [[4, 8], [8, 12], [1, 4]]` - Output: `1` - Explanation: In time order the meetings are `[1, 4)`, `[4, 8)` and `[8, 12)`, each starting exactly when the previous one ends, so one room is enough. **Example 3** - Input: `meetings = [[1, 5], [2, 6], [3, 7], [5, 9]]` - Output: `3` - Explanation: During `[3, 5)` the first three meetings are all in progress, so at least three rooms are needed. Three are enough, because `[5, 9)` can use the room that `[1, 5)` frees at time `5`.

Overview: Given meetings as half-open time intervals, find the smallest number of rooms needed so that no two meetings sharing a room overlap. Tests interval reasoning, correct handling of back-to-back meetings and duplicates, and an efficient solution for up to 100,000 meetings.

|Home/Coding & Algorithms/Google
Google logo
Google
Sep 7, 2026
mediumSoftware EngineerOnsiteCoding & Algorithms
0
0

You are given a list of meetings, where meetings[i] = [start, end] means meeting i occupies the half-open time interval [start, end). Every meeting must be held in one room for its whole interval, and two meetings can share a room only if their intervals do not overlap.

Return the minimum number of rooms needed to hold all the meetings.

Function Signature

def min_meeting_rooms(meetings: list[list[int]]) -> int:

Rules

  • Intervals are half-open: a meeting that ends at time t and a meeting that starts at time t do not overlap and may use the same room.
  • Meetings are given in no particular order. Identical intervals are separate meetings, and each needs its own room.
  • An empty list needs 0 rooms.

Constraints

  • 0 <= len(meetings) <= 10^5
  • Each meetings[i] contains exactly two integers with 0 <= start < end <= 10^9 .
  • The result is an integer from 0 to len(meetings) inclusive.

Examples

Example 1

  • Input: meetings = [[1, 10], [2, 6], [7, 12]]
  • Output: 2
  • Explanation: [1, 10) overlaps both other meetings, so it needs a room of its own. [2, 6) ends before [7, 12) starts, so those two can share a second room.

Example 2

  • Input: meetings = [[4, 8], [8, 12], [1, 4]]
  • Output: 1
  • Explanation: In time order the meetings are [1, 4) , [4, 8) and [8, 12) , each starting exactly when the previous one ends, so one room is enough.

Example 3

  • Input: meetings = [[1, 5], [2, 6], [3, 7], [5, 9]]
  • Output: 3
  • Explanation: During [3, 5) the first three meetings are all in progress, so at least three rooms are needed. Three are enough, because [5, 9) can use the room that [1, 5) frees at time 5 .

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...