Design and Implement Meeting Room Search and Booking
Model rooms with capacity and facilities, search for free rooms, and implement conflict-free booking where back-to-back slots are allowed.
Design a meeting room booking system for one office, and implement its core booking operation. Employees search for a free room and book it for a meeting, and they can cancel a booking later.
Each room has a name, a capacity (the most people it can hold), and a set of facilities such as a projector or a whiteboard. An employee searches by a time slot, the number of people, and the facilities they need, then books one of the rooms found. A room must never have two active bookings that overlap in time.
Back-to-back bookings are allowed: a booking from 09:00 to 10:00 and another from 10:00 to 11:00 in the same room are both fine.
For this exercise, assume: - The system runs in memory for a single office. Rooms are added by an administrator before booking starts; adding and editing rooms are not part of this exercise. - A time slot is a start time and an end time on the same timeline, and the start must be before the end.
A slot covers the start time but not the end time, so two slots overlap exactly when each one starts before the other one ends. - A search returns every room whose capacity is at least the number of people, that has all the requested facilities, and that has no active booking overlapping the slot.
Results are sorted by capacity from smallest to largest, then by room name. - A booking names the employee, the room, the slot, and the number of people. It succeeds only if the slot is valid, the room exists, the number of people fits the room, and the room is free for the whole slot.
Otherwise it fails with a clear reason and nothing changes. - Only the employee who made a booking can cancel it. A cancelled booking stays on record but no longer blocks the room. Cancelling a booking that is already cancelled changes nothing and says so.
- Recurring meetings, invitations, approvals, calendars of attendees, and storage are out of scope.
Explain how search and cancellation work. Then implement the booking operation in code or precise pseudocode.