Design a meeting room scheduler
medium 80 minBook a room for a slot, a number of people and some equipment, without ever booking one room twice: half-open slots, a sorted calendar for each room, rules that can be added, one lock, and then repeats, time zones and empty rooms.
Watch lesson4:39
Where it shows up
The same pattern appears across everyday software.
PostgreSQL: exclusion constraints
The manual's page on range types ends with a room reservation: `EXCLUDE USING GIST (room WITH =, during WITH &&)`. The database itself refuses the second booking.
Google Calendar: freeBusy.query
Takes a time window and a list of calendars and returns busy ranges only. The question is separate from reading events, so titles stay private.
Google Calendar: recurring events
A recurring event is stored as a rule. `events.instances()` expands it, and a changed instance is an exception to the rule.
Microsoft Graph: findMeetingTimes
Suggests times from the availability of attendees, with a minimum confidence that people can come, and returns a reason when there is no suggestion.
Exchange: resource mailboxes
A room is a mailbox with rules: `BookingWindowInDays`, `MaximumDurationInMinutes`, `ConflictPercentageAllowed` for repeated meetings. Our `BookingRule` objects, as settings.
Cal.com: slot reservation
Its API can reserve a slot for some minutes while a visitor fills in the form. A hold that runs out, in front of the booking.
iCalendar, RFC 5545
`RRULE` for the repeat, `EXDATE` for removed dates, `RECURRENCE-ID` for a changed instance, named by its original start.
Linux kernel: augmented red-black trees
The documentation uses an interval tree as its example: each node keeps the greatest end below it, so overlapping ranges can be found.
Java TreeMap
`floorEntry`, `lowerEntry` and `ceilingEntry` find neighbours in guaranteed log(n) time, which is the whole conflict search of this page.