← Uber Interview Insights

Uber·Machine Learning Engineer·Onsite - System Design / Architecture·Senior

SeniorPrefer not to say
Apr 2026

Summary

Uber MLE interview that went pretty deep into system design territory. The core problem was a referral-based revenue tracker and they wanted you to actually think through the tradeoffs, not just slap a hashmap on it and call it done.

Questions Asked (3)

Q1

Design and implement a customer revenue tracker where each customer can be referred by another customer. Effective revenue includes a customer's own revenue plus the recursive sum of all downstream referrals. Implement insertRevenue(customer_id, amount, referrer_id) and topK(k, threshold) returning the top k customers by effective revenue above a given threshold.

System DesignAlgorithms & Data StructuresTechnical Trade-offs
Author's notes

This one took me a minute to even parse.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements and scale, then propose a data model that supports efficient recursive revenue aggregation (e.g., tree with parent pointers and cached subtree sums). Discuss trade-offs between update and query performance, and outline algorithms for insertRevenue and topK with threshold, including complexity analysis.

Pro tip: Mention that real-world referral trees can be deep and skewed, so consider balancing techniques or incremental updates to avoid O(depth) per insert; also highlight the importance of handling cycles and invalid referrer IDs gracefully.

1. Clarify Requirements and Scale

Ask about expected number of customers, insert/query frequency, depth of referral trees, and whether revenue can be negative or updated. Clarify threshold semantics (strictly greater vs. greater or equal) and tie-breaking for topK.

2. Design Data Model

Propose a tree structure where each node stores customer_id, own revenue, parent (referrer), and cached effective revenue (subtree sum). Consider additional structures like a max-heap or sorted list for topK queries.

3. Implement insertRevenue

On insert, create node, link to referrer, and propagate the revenue delta up the ancestor chain, updating cached effective revenues. Discuss complexity: O(depth) per insert, and optimizations like path compression or lazy propagation.

4. Implement topK with Threshold

Maintain a global structure (e.g., balanced BST, heap, or sorted array) of customers by effective revenue. For topK, filter by threshold and return top k. Discuss trade-offs: heap gives O(n log k) per query, while maintaining sorted order gives O(log n) updates but O(k) query.

5. Analyze Trade-offs and Edge Cases

Compare approaches: naive recomputation vs. cached sums vs. segment trees. Discuss handling of cycles, invalid referrers, deep trees, and concurrent updates. Mention scalability and potential distributed solutions.

Key Points to Mention

  • Tree traversal and recursive aggregation: using DFS or parent pointers to compute effective revenue.
  • Caching subtree sums to avoid recomputation, with incremental updates on insert.
  • Complexity analysis: insert O(depth), topK O(n log k) or O(k) depending on structure.
  • Handling edge cases: cycles, invalid referrer_id, negative revenue, threshold inclusivity.
  • Scalability considerations: sharding, distributed aggregation, and eventual consistency.
  • Trade-offs between update-heavy vs. query-heavy workloads and choice of data structures (heap, BST, segment tree).

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

Q2

How would you handle cyclic referrals in the referral graph, and what edge cases arise when referrer information arrives after revenue events have already been recorded?

System DesignTechnical Trade-offsAlgorithms & Data Structures
Author's notes

They brought this up after I'd already committed to a tree structure, which was a bit awkward.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the referral graph's structure and the business context, then propose a cycle detection and resolution strategy (e.g., DFS with visited set, union-find, or time-based tie-breaking). Address late-arriving referrer data by discussing idempotent updates, backfilling, and reconciliation of revenue attribution, highlighting trade-offs between accuracy and latency.

Pro tip: Emphasize that in production systems like Uber's, you'd likely use a combination of real-time streaming (e.g., Flink) for immediate attribution and batch processing (e.g., Spark) for corrections, and always log raw events for auditability and replay.

1. Clarify requirements and graph model

Ask about the scale, whether cycles are allowed, and how referrals and revenue events are represented (e.g., directed edges, timestamps). Confirm if real-time or batch processing is expected.

2. Detect and resolve cycles

Propose algorithms like DFS with recursion stack, union-find, or topological sort to detect cycles. Discuss resolution strategies: break cycles by earliest referrer, ignore later edges, or use a decay/weighting scheme.

3. Handle late-arriving referrer data

Explain how to update revenue attribution when referrer info arrives after the event. Use idempotent writes, event sourcing, and backfilling with reconciliation to avoid double-counting.

4. Address edge cases and trade-offs

Cover cases like self-referrals, multiple referrers, out-of-order events, and data consistency. Discuss trade-offs between accuracy, latency, and system complexity.

5. Propose a scalable architecture

Outline a lambda architecture: stream processing for real-time attribution and batch processing for corrections. Mention storage (e.g., graph DB, columnar store) and monitoring.

Key Points to Mention

  • Cycle detection algorithms: DFS with visited set, union-find, topological sort
  • Cycle resolution: time-based tie-breaking, edge pruning, or probabilistic attribution
  • Late data handling: event sourcing, idempotent updates, backfilling, reconciliation
  • Trade-offs: real-time vs batch, accuracy vs latency, complexity vs maintainability
  • Scalability: distributed graph processing (e.g., Pregel), partitioning, and indexing
  • Business impact: fraud prevention, incentive correctness, and user experience

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

Q3

What data structures would you use to keep topK queries efficient as inserts stream in continuously?

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

Basically asking whether a heap, sorted set, or something else makes sense here.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem constraints: what is K, what is the data type, and what are the latency and memory requirements? Then propose a min-heap of size K as the baseline solution, and discuss optimizations like a hash map for deduplication or a balanced BST for ordered traversal. Finally, compare trade-offs and mention distributed approaches if the scale is large.

Pro tip: Mention that for very large K or high-throughput streams, a probabilistic data structure like Count-Min Sketch combined with a heap can provide approximate top-K with bounded error, which is often acceptable in practice. Also, highlight that Uber's real-time ML pipelines often use Flink or Kafka Streams, so integrating with such systems is key.

1. Clarify requirements

Ask about the size of K, the data type (e.g., integers, strings), whether duplicates matter, and the required latency and memory constraints.

2. Propose baseline solution

Suggest a min-heap of size K to maintain the top K elements. For each insert, compare with the heap root and replace if larger, giving O(log K) per insert.

3. Discuss optimizations

If duplicates or updates are frequent, use a hash map to track counts and a heap for ordering. For ordered traversal, consider a balanced BST or skip list.

4. Address scalability

For high-throughput streams, discuss distributed approaches like sharding the stream and merging local top-K results, or using approximate algorithms like Count-Min Sketch.

5. Summarize trade-offs

Conclude by comparing time/space complexity, accuracy, and implementation complexity of each approach, and recommend one based on the constraints.

Key Points to Mention

  • Min-heap of size K for O(log K) insert and O(1) access to the K-th largest.
  • Hash map for frequency counting when duplicates or updates are involved.
  • Balanced BST or skip list for maintaining sorted order if needed.
  • Count-Min Sketch for approximate top-K with sublinear space.
  • Distributed processing with sharding and merging for scalability.
  • Trade-offs between exact vs approximate, latency vs memory, and implementation complexity.

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