← Uber Interview Insights

Uber·Machine Learning Engineer·Technical Phone Screen·Senior

SeniorPrefer not to say
May 2026

Summary

Uber MLE interview focused entirely on the merge sorted lists problem, starting simple and then scaling it up. Pretty classic algorithmic session, nothing flashy.

Questions Asked (2)

Q1

Given two sorted sequences, merge them into a single sorted sequence as efficiently as possible.

Algorithms & Data Structures
Author's notes

Two pointers, linear time, nothing surprising.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem constraints (e.g., input sizes, memory limits, whether the sequences are arrays or linked lists) and then propose the standard two-pointer merge algorithm with O(n+m) time and O(n+m) space. Discuss how this applies to ML pipelines at Uber, such as merging sorted feature lists or time-series data, and mention potential optimizations like in-place merging for arrays or using a min-heap for k-way merging if extended.

Pro tip: Emphasize that while the two-pointer approach is optimal for two sequences, you should also discuss trade-offs and edge cases (e.g., one sequence much larger, memory constraints) to show depth. Mention that in production ML systems, you might use built-in functions like `merge` from `heapq` or `np.concatenate` followed by sorting, but only if the data is small; otherwise, the linear merge is preferred.

1. Clarify constraints and assumptions

Ask about input types (arrays, linked lists), sizes, memory limits, and whether the sequences are sorted in ascending order. Confirm if extra space is allowed or if in-place merging is required.

2. Propose the two-pointer algorithm

Initialize pointers at the start of each sequence and compare elements, appending the smaller one to the result and advancing that pointer. Continue until one sequence is exhausted, then append the remainder of the other.

3. Analyze time and space complexity

State that the algorithm runs in O(n+m) time and uses O(n+m) extra space for the output. Mention that if merging in-place (e.g., for arrays with extra space at the end), space can be O(1).

4. Discuss edge cases and optimizations

Cover cases like empty sequences, one sequence much larger, duplicate elements, and stability. For linked lists, the same approach works without extra space. For k-way merging, suggest using a min-heap.

5. Relate to ML engineering at Uber

Connect the problem to real-world ML tasks, such as merging sorted feature vectors, combining ranked lists from different models, or processing time-series data. Highlight efficiency and scalability.

Key Points to Mention

  • Two-pointer technique for linear time complexity
  • Time complexity O(n+m) and space complexity O(n+m) (or O(1) for in-place)
  • Handling edge cases: empty inputs, duplicates, unequal lengths
  • Stability of merge (preserving order of equal elements)
  • Alternative approaches: heapq.merge for k-way, in-place merge for arrays
  • Relevance to ML pipelines: merging sorted features, ranked lists, or time-series data

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

Q2

Now generalize: given K sorted sequences, merge them all into one sorted sequence. What's your approach and what's the time complexity?

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

This is where it got more interesting.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem constraints (e.g., K and total elements N, memory limits) and then present the standard heap-based K-way merge. Explain the algorithm step-by-step and derive the time complexity O(N log K), highlighting why it's optimal for large K. Optionally, mention alternative approaches like divide-and-conquer merge and their trade-offs.

Pro tip: Emphasize that the heap size is K, not N, which makes the solution memory-efficient and scalable. Also, discuss how this applies to distributed settings (e.g., merging sorted shards in MapReduce) to show practical ML engineering relevance.

1. Clarify constraints and assumptions

Ask about the number of sequences (K), total elements (N), memory limits, and whether sequences are stored in memory or on disk. This shows you consider real-world constraints.

2. Describe the heap-based approach

Explain that you initialize a min-heap with the first element of each sequence. Then repeatedly extract the minimum, append it to the output, and insert the next element from the same sequence until all are exhausted.

3. Analyze time and space complexity

Derive time complexity: each of N elements is inserted and extracted from a heap of size K, giving O(N log K). Space complexity is O(K) for the heap plus O(N) for the output.

4. Discuss alternatives and trade-offs

Mention divide-and-conquer pairwise merging (O(N log K) time, but higher memory) and the naive approach of merging sequentially (O(NK) time). Compare based on K, N, and memory.

5. Connect to ML engineering context

Relate to merging sorted feature lists, distributed sorting in large-scale ML pipelines, or merging results from multiple models. Highlight scalability and practical implementation details.

Key Points to Mention

  • Min-heap of size K storing (value, sequence_index) pairs
  • Time complexity O(N log K) where N is total elements and K is number of sequences
  • Space complexity O(K) for heap, O(N) for output
  • Comparison with divide-and-conquer merge: O(N log K) time but O(N) extra space
  • Handling edge cases: empty sequences, K=1, K > N
  • Applicability to distributed systems and external sorting

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