← Uber Interview Insights

Uber·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Uber SWE coding round with a deceptively tricky step-function problem that looks familiar but isn't. The problem description alone took a while to parse correctly, and I spent more time than I'd like to admit just figuring out what the input even meant.

Questions Asked (1)

Q1

Given two arrays of (timestamp, value) tuples representing step functions, merge them into a single step function where each segment's value is the sum of the two input functions at that point in time.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

The first thing I did wrong was assume I knew what the tuple format meant and just started coding.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the representation of step functions (e.g., segments defined by start time and value, with value constant until next timestamp) and handle edge cases like empty arrays or duplicate timestamps. Use a two-pointer technique to traverse both arrays in chronological order, merging timestamps and summing values, while maintaining the current value from each function. Output the merged step function as a list of (timestamp, value) pairs where the value changes only when necessary.

Pro tip: Demonstrate awareness of real-world applications at Uber, such as merging pricing or demand curves, and discuss trade-offs between time and space complexity, especially if the input arrays are large or streamed.

1. Clarify input format and assumptions

Ask whether each tuple represents the start of a segment with a constant value until the next timestamp, and confirm that timestamps are sorted. Discuss handling of duplicate timestamps and empty arrays.

2. Design two-pointer merge algorithm

Use two pointers to iterate through both arrays simultaneously, always advancing the one with the smaller timestamp. At each step, compute the sum of the current values from both functions and append a new segment if the sum differs from the previous.

3. Handle edge cases and output format

Ensure the output only includes points where the sum changes, and handle cases where one array is exhausted by continuing with the other's remaining segments. Discuss whether to include zero-value segments.

4. Analyze complexity and trade-offs

State that time complexity is O(m+n) and space O(m+n) for the output. Mention potential optimizations like in-place merging if one array has extra capacity, or streaming if data is too large.

5. Test with examples

Walk through a simple example, such as A = [(0,1), (5,2)] and B = [(2,3), (7,4)], to verify correctness and illustrate the merging process.

Key Points to Mention

  • Two-pointer technique for merging sorted arrays
  • Step function representation: (timestamp, value) where value applies from that timestamp until the next
  • Handling duplicate timestamps by summing values at the same time
  • Time and space complexity analysis (O(m+n) time, O(m+n) space for output)
  • Edge cases: empty arrays, single-element arrays, all timestamps in one array before the other
  • Real-world relevance at Uber (e.g., merging pricing, demand, or supply step functions)

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