← Uber Interview Insights

Uber·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Uber SWE interview with a scheduling/interval problem that looked deceptively simple but had a real efficiency angle baked in. The kind of question where getting a working solution isn't enough, they want you to think about what sorted order actually buys you.

Questions Asked (1)

Q1

You have multiple meeting rooms, each with a sorted list of non-overlapping booked intervals. Given a new meeting interval, find any room where it can be inserted without causing a conflict, or return -1 if none exist. How do you do this efficiently?

Algorithms & Data Structures
Author's notes

My first instinct was to just loop through every room and every interval inside it, which works but is obviously brute force.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

For each room, use binary search to find the insertion point of the new meeting's start time, then check the previous and next intervals for overlap. Return the first room where no conflict exists, or -1 if none. This yields O(m log n) time where m is the number of rooms and n is the average number of intervals per room.

Pro tip: Mention that if the number of rooms is large and queries are frequent, you could preprocess each room's intervals into a balanced BST or use a segment tree to answer queries in O(log n) per room, but binary search is optimal for a single query. Also, clarify edge cases like empty rooms or intervals at boundaries.

1. Clarify the problem and constraints

Confirm that intervals are sorted and non-overlapping within each room, and that the new meeting must fit entirely without overlapping any existing booking. Ask about the expected number of rooms and intervals to choose the right algorithm.

2. Design the per-room check

For a given room, use binary search to find the index where the new meeting's start time would be inserted. Then check if the previous interval's end time is less than or equal to the new start, and the next interval's start time is greater than or equal to the new end.

3. Iterate over rooms and return result

Loop through each room, perform the check, and return the room index as soon as a valid insertion point is found. If no room works, return -1.

4. Analyze time and space complexity

State that the time complexity is O(m log n) where m is the number of rooms and n is the average number of intervals per room, and space complexity is O(1) extra. Discuss potential optimizations if needed.

5. Handle edge cases and test

Consider cases like empty rooms, meetings that fit at the beginning or end of a room's schedule, and intervals that exactly touch (e.g., new end equals existing start). Walk through a small example to verify correctness.

Key Points to Mention

  • Binary search to find the insertion point in each room's sorted intervals.
  • Overlap condition: new interval conflicts if previous.end > new.start or next.start < new.end.
  • Time complexity O(m log n) and space complexity O(1).
  • Edge cases: empty room, insertion at boundaries, exact touching intervals.
  • Alternative data structures for frequent queries (e.g., segment tree, balanced BST).
  • Early termination: return the first valid room to save time.

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