Meeting room reservation (OOD)
You are designing a small in-memory meeting reservation system.
Requirements
-
The system starts with
N meeting rooms
(e.g.,
rooms = ["A", "B", "C"]
).
-
Implement a booking method that receives a
start time
and
end time
for a meeting.
-
If there exists
any room
that is
available for the entire interval
[start, end)
(end is non-inclusive), the system should:
-
reserve that room for the interval
-
return a
unique
meetingId
representing the booking
-
If
no room
is available for that time interval, the method should
throw an exception
(or return an error).
Clarifications / assumptions (you may state these in your design)
-
Time can be represented as integers (e.g., minutes since epoch).
-
start < end
is guaranteed.
-
A meeting overlaps another if their half-open intervals intersect.
-
The solution should be reasonably efficient as the number of rooms and reservations grows.
What to produce
-
The main classes / data structures you would create.
-
The
book(start, end) -> meetingId
API behavior.
-
How you check availability and store reservations.
-
Expected time/space complexity.
-
(Optional, if you choose) how you would support
cancel(meetingId)
and/or querying room schedules.