2dbi

Design a Meeting Scheduler

viaLeetCode

Problem Design a meeting scheduler: book rooms/time slots, detect conflicts, and find slots that work for a set of participants — covering class design and the service view.

Requirements

  • bookMeeting(organizer, participants, duration, window, room?) → confirmed slot or alternatives; cancel/reschedule; per-user and per-room calendars; find common free slots for N participants.

Core design

  • Classes: User, Room(capacity, features), Meeting(id, organizer, participants, interval, room), Calendar per bookable resource (user/room) holding a time-sorted interval structure (TreeMap keyed by start) with addIfFree(interval) conflict check — overlap test against floor/ceiling neighbors in O(log n).
  • SchedulerService: intersect participants' free time — collect busy intervals, merge (sort + sweep), complement within working hours, then match against room availability; RoomFinder strategy (capacity/feature filters).

Discussion points

  • Conflict detection correctness: half-open intervals, back-to-back meetings allowed; the merge-intervals sweep as the core algorithm.
  • Concurrency: two organizers booking the same room slot — lock per resource calendar or optimistic version check; idempotent booking API.
  • Service/scale view: calendars partitioned by user/room, recurring meetings (RRULE expansion vs materialization), notifications and invitations as async events, time zones as the classic trap.
Add a follow-up question they asked
No follow-ups yet. Be the first to add one.
asked …
LeaderboardSalary
Language
Account