Reject Conference Room Bookings That Would Cause a Double Booking
Last updated: November 29, 2026
Quick Overview
Implement a booking class for one conference room with book(start, end) that accepts a half-open [start, end) reservation only if it overlaps no existing booking, returning True when accepted and False otherwise.
Meta
November 29, 20260
0
0 solved
Implement a booking class for one conference room with book(start, end) that accepts a half-open [start, end) reservation only if it overlaps no existing booking, returning True when accepted and False otherwise.
Meta's internal room-booking tools face exactly this constraint, and the question shows up in technical screens to test ordered-structure thinking. The interviewer wants you to move past a linear scan to a sorted structure where you only need to check the two neighbors of the insertion point.
What the Interviewer Expects
- Starts with the O(n) per call scan and its overlap test
- Realizes only the predecessor and successor bookings can conflict
- Uses binary search over sorted starts
- Discusses that list insertion is O(n) and a balanced tree or skip list gives O(log n)
- Handles touching bookings as allowed
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you allow up to two overlapping bookings (double but not triple)?
- How would you support cancellation?
- How does this change when there are many rooms and the user wants any free room?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
API: RoomCalendar() then repeated book(start, end) calls with start < end. Accept only if the new interval does not overlap any accepted interval. Touching is fine because the intervals are half-o...
High-Level Design
Keep accepted bookings sorted by start. Since accepted bookings never overlap each other, they are also sorted by end. For a new [s, e), find the insertion index i of s among starts. The only bo...