← Questions

Busiest meeting room after simulated bookings

0
GoogleCodingLast asked Mar 2026

A coding interview question asked in Google's onsite coding round, last asked Mar 2026. It tests heaps, simulation and intervals.

Simulate booking meetings into n rooms numbered 0 to n - 1, and return the room that held the most meetings. Agree on the rules first; unless the interviewer sets others, use these:

  • Meetings are handled in order of start time (all start times are distinct).
  • A meeting takes the free room with the lowest number.
  • If no room is free, the meeting waits for the room that frees up first (lowest number on a tie) and keeps its original duration.
  • A room freed at time t is free for a meeting starting at t.

Interface

Unless you agree on a different interface with the interviewer, assume:

  • busiest_room(n: int, meetings: list[list[int]]) -> int — each meeting is [start, end). Return the room with the most meetings; on a tie, the lowest number.

Example

busiest_room(2, [[0,10], [1,5], [2,7], [3,4]])                  ->  0
# [0,10) -> room 0; [1,5) -> room 1; [2,7) waits for room 1, runs [5,10);
# [3,4): both rooms free up at 10, so it takes room 0 and runs [10,11)
# rooms 0 and 1 both held 2 meetings: the lower number wins

busiest_room(3, [[1,20], [2,10], [3,5], [4,9], [6,8]])          ->  1

Constraints

  • 1 <= n <= 100; up to 10^5 meetings; times up to 5 * 10^5 (delayed end times can grow larger: use 64-bit integers).

Clarifying questions

  • Which free room does a meeting take?
  • What happens when no room is free: wait, or the meeting is dropped?
  • If a meeting is delayed, does it keep its duration?
  • How are ties broken, both between rooms freeing at the same time and between rooms with equal counts?

What a strong answer covers

  • Sort meetings by start. Keep two heaps: free rooms by number, and busy rooms by (end_time, room).
  • For each meeting, first move every busy room with end_time <= start back to the free heap. If a room is free, take the lowest; otherwise pop the earliest-ending busy room and schedule the meeting from its end time with the same duration.
  • O(m log n) time; a count per room.
  • Tests: one room, no delays, every meeting delayed, simultaneous end times.

Follow-ups

  • Meetings that cannot start within d units of their requested time are dropped.
  • Rooms have capacities and meetings have sizes.
  • Return the full schedule (room and actual start for each meeting).

Where it's asked

  • Google · Onsite coding · Last asked Mar 202645 min · Usually two rounds, mostly in person: whiteboard plus a Chromebook with Google Docs · No AI (a pilot code-comprehension round lets candidates use Gemini)

What it tests

heaps · simulation · intervals

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding