Home/Low-level design/Meeting Room Booking System

Meeting Room Booking System

Interval conflicts and atomic room allocation

Two half-open intervals overlap exactly when each starts before the other ends. Strict inequalities permit one meeting to begin exactly as another ends. Invalid empty or reversed intervals must be rejected before checking overlap.

cpp
bool overlap = a_start < b_end && b_start < a_end;
// [10,20) and [20,30) do not overlap.

Multi-room requests require a plan before commitment. Reserving the first eligible room and then discovering no second room leaves a leaked reservation. Gather all candidates, sort by capacity and ID, and commit only if enough exist. Successful IDs remain reserved after cancellation; failed requests retain the ability to retry. Keep lifetime ID history separate from active bookings. Return the original selection order from allocation, while schedule uses time order. Copying room configuration prevents later caller mutations changing availability rules.

C++ contract conventions: numeric values use signed Int (long long); all inputs and intermediate arithmetic are within its representable range. Opt<T> means std::optional<T> and absence is std::nullopt; Vec<T> means std::vector<T>. Invalid documented arguments throw std::invalid_argument. Inputs passed by const reference remain caller owned. Returned containers and records own their contents. Calls use the declared C++ parameter types. Implicit conversions performed by the caller are outside the runtime validation contract. Unless a lesson states otherwise, string ordering is lexicographic over Unicode code points (Text) or UTF-8 identifiers (std::string).

Put it into practice

Implement the exercise in a full-screen workspace, then run its tests.

Open practice
Next lessonExpense Sharing System