Assign Calendar Meetings to the Lowest-Numbered Free Room

Last updated: November 29, 2026

Quick Overview

There are n rooms numbered 0 to n-1 and meetings with distinct start times. Each meeting takes the lowest-numbered free room; if none is free it is delayed until the earliest room frees (keeping its duration). Return the room that hosted the most meetings, lowest number on ties.

Google
Coding & Algorithms
Software Engineer
Google
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

0

0 solved


There are n rooms numbered 0 to n-1 and meetings with distinct start times. Each meeting takes the lowest-numbered free room; if none is free it is delayed until the earliest room frees (keeping its duration). Return the room that hosted the most meetings, lowest number on ties.

A Google onsite simulation modeled on Calendar room booking for a busy office. The interviewer checks two heaps (free rooms by number, busy rooms by end time then number), correct delay handling, and 64-bit end times.

What the Interviewer Expects
  • Sorts meetings by start time
  • Uses a min-heap of free room numbers
  • Uses a min-heap of (end time, room) for busy rooms
  • Delays a meeting by its duration when all rooms are busy
  • Counts per room and picks the lowest index on ties
Key Topics to Cover
Two Heaps
Simulation
Scheduling
Intervals
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • Return each meeting's actual start time
  • What if meetings have priorities?
  • How would you shard this across buildings?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements
  • Input: n rooms, list of (start, end) half-open meetings with unique starts.
  • A meeting uses the lowest-numbered room free at its start. If none, it waits for the earliest-freeing room (smallest n...
High-Level Design

Process meetings in order of start. Keep free, a min-heap of room numbers, and busy, a min-heap of (end_time, room).

For a meeting (s, e): release every busy room with end_time <= s back in...


Submit Your Answer
Markdown supported