Code RoomMeeting room assignment
HardPrep Room Coding #993

Meeting room assignment

CodingAlgorithms & data structuresSenior–Staff~35 min

You are given meetings as a list of [start, end) half-open intervals. There are exactly n rooms numbered 0..n-1. Meetings are assigned greedily: process meetings in order of start time (break ties by the earlier start, then by the order given), and assign each meeting the lowest-numbered room that is free; if all rooms are busy, the meeting is delayed until the earliest room frees up, keeping its original duration but starting when that room becomes free (still preferring the lowest-numbered room among those that free at that time). Return the room number that held the most meetings (ties broken by lowest room number). n is up to 100 and there are up to 10^4 meetings; times fit in 64-bit ints.

Implement
most_booked_room(n: int, meetings: list[list[int]]) → int
Examples
in[2,[[0,10],[1,5],[2,7],[3,4]]]out0
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 35 min
InputExpectedGot
[2,[[0,10],[1,5],[2,7],[3,4]]]0not run yetsample