Book Vehicle Inspection Slots Without Overlapping Reservations

Last updated: November 29, 2026

Quick Overview

Build a booking class for a single vehicle inspection bay. book(start, end) reserves the half-open interval [start, end) and returns True, unless it overlaps an existing booking, in which case it returns False and stores nothing.

Uber
Coding & Algorithms
Software Engineer
Uber
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Easy

0

0

0 solved


Build a booking class for a single vehicle inspection bay. book(start, end) reserves the half-open interval [start, end) and returns True, unless it overlaps an existing booking, in which case it returns False and stores nothing.

A common Uber phone screen warm-up rooted in driver onboarding, where drivers book inspection slots at Greenlight hubs. It checks whether you can keep intervals ordered and look only at neighbors instead of scanning everything.

What the Interviewer Expects
  • Defines overlap correctly for half-open intervals
  • Keeps bookings sorted by start and checks only the predecessor and successor
  • Uses bisect for O(log n) search
  • Notes that list insertion is O(n) and names a balanced tree for true O(log n)
  • Writes clean class code with tests
Key Topics to Cover
ordered set
binary search
intervals
bisect
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • Allow up to two overlapping bookings (two bays) and reject a triple overlap.
  • How would you support cancellation?
  • What if bookings arrive from many hubs concurrently?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements
  • book(start, end) with start < end, half-open interval.
  • Return True and store it if it overlaps nothing, otherwise False.
  • Touching intervals like [10, 20) and [20, 30) do not overlap....
High-Level Design

Because accepted bookings never overlap, sorting them by start also sorts them by end. For a new interval, only two existing bookings can conflict: the one with the largest start below the new start (...


Submit Your Answer
Markdown supported