Meeting Rooms II

Free with account Updated Nov 19, 2026 · 5 min read
On this page

    Problem statement

    Given a list of meetings as [start, end] times, return the minimum number of conference rooms needed so that no two meetings in the same room overlap. A meeting that ends at time t frees its room for a meeting that starts at t.

    This is the classic "how many things happen at once" question, and it shows up in many forms: servers needed for jobs, platforms for trains, CPU cores for tasks. Original problem: LeetCode 253 (premium).

    Example

    The long meeting from 0 to 30 needs its own room, and the two short meetings can share a second room, so two rooms are enough.
    The long meeting from 0 to 30 needs its own room, and the two short meetings can share a second room, so two rooms are enough.
    Input:  [[0, 30], [5, 10], [15, 20]]
    Output: 2
    Input:  [[7, 10], [2, 4]]
    Output: 1

    Constraints (assumed)

    • 0 ≤ n ≤ 10,000.
    • 0 ≤ start < end ≤ 10⁶.

    What this question tests

    • Translating the story into "the maximum number of overlapping intervals".
    • Using sorting plus a heap (or two sorted arrays) to track what's active.
    • Boundary handling: does ending at 10 conflict with starting at 10?

    Questions to ask first

    1. Does a meeting ending at t conflict with one starting at t? (Here: no, the room is free.)
    2. Is the input sorted? (Here: no.)
    3. Do you need the room assignment or just the count? (Here: the count.)
    4. How large are the times? Large times rule out an array indexed by time.