← Uber Interview Insights

Uber·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Uber SWE coding round with one algorithmic problem centered on interval processing. The problem was well-scoped but had enough edge cases to trip you up if you weren't careful about how simultaneous start/end events interact.

Questions Asked (1)

Q1

Given a list of courier working intervals [start, end) that may overlap, return a timeline broken into segments [segmentStart, segmentEnd, activeCount], where each segment represents a period of constant courier activity. Only emit segments where at least one courier is active, and treat all changes at the same timestamp as a single atomic event before computing the next segment.

Algorithms & Data Structures
Author's notes

The core idea clicks fast: sweep line, collect all the events, sort them, walk through.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use a sweep-line algorithm: create events for each interval start (+1) and end (-1), sort them by time, and then process events in order while maintaining a running count of active couriers. Group events with the same timestamp to handle simultaneous changes atomically, and emit segments only when the active count is positive.

Pro tip: Emphasize the atomic handling of simultaneous events: if one courier ends and another starts at the same time, the active count should not drop to zero between them. This shows attention to edge cases and real-world correctness.

1. Clarify assumptions and edge cases

Confirm that intervals are half-open [start, end), may overlap, and that all changes at the same timestamp are processed together. Discuss handling of empty input, zero-length intervals, and large datasets.

2. Generate events

For each interval, create a start event with delta +1 and an end event with delta -1. Store events as tuples (time, delta).

3. Sort and group events by time

Sort events by time. Then iterate through the sorted events, grouping all events with the same timestamp to compute the net change in active couriers atomically.

4. Sweep and emit segments

Maintain a running active count. For each group of events at time t, first apply the net delta, then if the active count is positive, emit a segment from t to the next event time with the current active count.

5. Analyze complexity and test

State that time complexity is O(n log n) due to sorting, and space is O(n). Walk through a small example to verify correctness, including simultaneous events.

Key Points to Mention

  • Sweep-line algorithm with events for interval starts and ends
  • Atomic processing of simultaneous events to avoid incorrect zero-count segments
  • Half-open interval semantics [start, end) and how it affects event ordering
  • Time complexity O(n log n) and space complexity O(n)
  • Edge cases: empty input, no active couriers, overlapping intervals, zero-length intervals
  • Emitting segments only when active count > 0

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