← Uber Interview Insights

Uber·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Jul 2026

Summary

Uber SWE interview with a calendar interval problem. Pretty standard algorithmic question but the half-open interval detail is the kind of thing that'll trip you up if you're not careful.

Questions Asked (1)

Q1

Design and implement a calendar class that books time intervals [start, end), rejecting any new booking that overlaps with an existing one. Return true if the booking succeeds, false otherwise.

Algorithms & Data Structures
Author's notes

The half-open interval part is where I slipped up initially.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the requirements and constraints, then propose a solution using a balanced binary search tree (e.g., TreeMap) to store intervals sorted by start time. For each new booking, check for overlap with the immediate predecessor and successor intervals, and insert if no conflict. Discuss time and space complexity, and consider edge cases and potential optimizations.

Pro tip: Mention that using a TreeMap allows O(log n) insertion and overlap checking, but also discuss the trade-offs with other data structures like sorted lists or interval trees, showing you understand scalability for Uber's high-throughput systems.

1. Clarify requirements and constraints

Ask about expected number of bookings, concurrency needs, and whether intervals are half-open [start, end). Confirm return type and error handling.

2. Choose data structure

Propose a balanced BST (e.g., TreeMap in Java) keyed by start time to maintain sorted intervals and enable efficient predecessor/successor queries.

3. Design booking logic

For a new interval, find the floor and ceiling entries. Check if the new interval overlaps with either; if not, insert and return true, else return false.

4. Analyze complexity and edge cases

State O(log n) time per booking and O(n) space. Discuss edge cases: empty calendar, adjacent intervals, exact duplicates, and intervals with zero duration.

5. Implement and test

Write clean code with helper methods for overlap checking. Walk through examples and consider unit tests for boundary conditions.

Key Points to Mention

  • Use of balanced BST (TreeMap) for O(log n) operations
  • Overlap condition: new.start < existing.end && new.end > existing.start
  • Handling half-open intervals [start, end) correctly
  • Checking only predecessor and successor intervals for overlap
  • Time and space complexity analysis
  • Potential concurrency considerations for multi-threaded environments

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.