← Back to problems

7. Meeting Room Scheduler

MEDIUM
DESIGNIntervalsLLDScheduling

Assign meetings to a fixed set of rooms greedily, handling arbitrary arrival order, cancellations, and point-in-time queries.

Manage a fixed number of meeting rooms. Each booking occupies a half-open interval [start, end): two meetings conflict only if their intervals overlap, so [1,3) and [3,5) do NOT conflict (touching endpoints are fine). Bookings do NOT arrive in time order. Commands: - INIT <rooms> : number of rooms, with ids 1..rooms. - BOOK <id> <start> <end> : assign this booking to the LOWEST-id room that is free for the entire interval [start, end); print "ROOM <r>". If no room is free for that interval, print "REJECTED". - CANCEL <id> : remove a booking; print "CANCELLED", or "NOBOOKING" if that id is not currently booked. - QUERY <t> : print the number of meetings active at time t, i.e. bookings with start <= t < end.
Log in to submit a solution

Comments

Log into join the discussion.