← Uber Interview Insights

Uber·Software Engineer·Online Assessment (OA)·Intermediate

Intermediate
Jul 2026

Summary

Uber SWE OA, one algorithmic problem about simulating round-trip mission scheduling across two sorted timetables. Pretty niche problem, felt like it was pulled from an older CodeSignal bank rather than something freshly written.

Questions Asked (1)

Q1

Given two sorted arrays of departure times from locations A and B, and a mission count m, simulate m round trips (A to B and back, each leg taking 100 time units, always catching the next available departure). Return the earliest time the last mission completes back at A.

Algorithms & Data Structures
Author's notes

I went with binary search first because two pointers felt fiddly to get right under pressure.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the problem as a simulation where for each mission, you find the earliest departure from the current location that is at or after the current time, then add the travel time. Use binary search (or two pointers) on the sorted departure arrays to efficiently find the next departure, and repeat for m round trips.

Pro tip: Clarify whether the arrays are 0-indexed and if there are multiple identical departure times; also confirm if the traveler can wait at a location for any amount of time. This shows attention to edge cases and prevents off-by-one errors.

1. Clarify assumptions and edge cases

Confirm that each leg takes exactly 100 time units, that the traveler always takes the next available departure at or after arrival, and that m can be zero. Ask about duplicate departure times and whether the arrays are sorted ascending.

2. Define state and simulation loop

Initialize current time to 0 and current location to A. For each of the m missions, simulate the outbound leg (A to B) and return leg (B to A) by finding the next departure and adding 100.

3. Efficiently find next departure

Use binary search (lower_bound) on the sorted departure array to find the first departure time >= current time. If none exists, the mission cannot be completed (handle as needed).

4. Update time and location

After finding the departure, set current time to departure + 100 (arrival time) and switch location. Repeat for each leg.

5. Return final time

After completing all m round trips, the current time is the earliest time the last mission completes back at A. Return that value.

Key Points to Mention

  • Binary search (lower_bound) to find the next departure in O(log n) per leg, leading to O(m log n) total time.
  • Two-pointer approach if the arrays are traversed sequentially, but binary search is more straightforward for arbitrary m.
  • Handling of edge cases: no available departure, m=0, duplicate departure times, and large m requiring efficient simulation.
  • Time complexity analysis: O(m log n) vs O(m + n) with two pointers if m is large and arrays are small.
  • Space complexity: O(1) extra space beyond input arrays.
  • Correctness: always catching the next available departure minimizes waiting time and thus the completion time.

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