Minimum Number of Rooms to Host Overlapping Meetings

Read the full interview experience this question came from →

Quick Overview

Given a list of meetings with start and end times, compute the fewest rooms needed so that no two overlapping meetings share a room. The problem tests interval reasoning, careful handling of a meeting that ends exactly when another begins, and an efficient approach that scales to 100,000 meetings.

Minimum Number of Rooms to Host Overlapping Meetings

Company: Palantir

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

You are given a list of meetings, each with a start time and an end time. Every meeting must be held in a room, and a room can host only one meeting at a time. Return the smallest number of rooms that lets every meeting take place at its scheduled time. A meeting `[start, end]` occupies its room over the half-open interval from `start` up to, but not including, `end`. A meeting that ends at time `t` and another that starts at time `t` can therefore use the same room. ### Function Signature ```python def min_rooms(meetings: list[list[int]]) -> int: ``` ### Rules - `meetings[i] = [start_i, end_i]` describes meeting `i`. - Two meetings conflict exactly when their half-open intervals overlap, that is, when `start_a < end_b` and `start_b < end_a`. - Meetings may be given in any order. Identical meetings may appear more than once, and each copy needs its own room. - An empty list needs `0` rooms. - The answer is a single integer, so it is unique. ### Constraints - `0 <= len(meetings) <= 10^5` - `0 <= start_i < end_i <= 10^9` - All values fit in a 32-bit signed integer. ### Examples **Example 1** Input: `meetings = [[9, 12], [10, 11], [11, 13], [10, 14]]` Output: `3` Explanation: during `[10, 11)` three meetings run at once: `[9, 12]`, `[10, 11]` and `[10, 14]`. When `[10, 11]` ends at time 11, `[11, 13]` can take over its room, so no moment ever needs a fourth room. **Example 2** Input: `meetings = [[4, 7], [7, 9], [1, 4]]` Output: `1` Explanation: the meetings run back to back, and each starts exactly when the previous one ends, so a single room is enough. **Example 3** Input: `meetings = []` Output: `0`

Overview: Given a list of meetings with start and end times, compute the fewest rooms needed so that no two overlapping meetings share a room. The problem tests interval reasoning, careful handling of a meeting that ends exactly when another begins, and an efficient approach that scales to 100,000 meetings.

Read the full Palantir Software Engineer interview experience this question came from

Palantir logo
Palantir
Jan 30, 2026
mediumSoftware EngineerTechnical ScreenCoding & Algorithms
1
0

You are given a list of meetings, each with a start time and an end time. Every meeting must be held in a room, and a room can host only one meeting at a time. Return the smallest number of rooms that lets every meeting take place at its scheduled time.

A meeting [start, end] occupies its room over the half-open interval from start up to, but not including, end. A meeting that ends at time t and another that starts at time t can therefore use the same room.

Function Signature

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

Rules

  • meetings[i] = [start_i, end_i] describes meeting i .
  • Two meetings conflict exactly when their half-open intervals overlap, that is, when start_a < end_b and start_b < end_a .
  • Meetings may be given in any order. Identical meetings may appear more than once, and each copy needs its own room.
  • An empty list needs 0 rooms.
  • The answer is a single integer, so it is unique.

Constraints

  • 0 <= len(meetings) <= 10^5
  • 0 <= start_i < end_i <= 10^9
  • All values fit in a 32-bit signed integer.

Examples

Example 1

Input: meetings = [[9, 12], [10, 11], [11, 13], [10, 14]] Output: 3

Explanation: during [10, 11) three meetings run at once: [9, 12], [10, 11] and [10, 14]. When [10, 11] ends at time 11, [11, 13] can take over its room, so no moment ever needs a fourth room.

Example 2

Input: meetings = [[4, 7], [7, 9], [1, 4]] Output: 1

Explanation: the meetings run back to back, and each starts exactly when the previous one ends, so a single room is enough.

Example 3

Input: meetings = [] Output: 0