← Uber Interview Insights

Uber·Machine Learning Engineer·Technical Phone Screen·Senior

SeniorPrefer not to say
Jun 2026

Summary

Uber MLE interview with a coding round focused on data structure design. The problem was more involved than a typical LeetCode question and pushed into system-ish territory, which I wasn't fully expecting.

Questions Asked (1)

Q1

Design and implement an in-memory revenue tracking system for a referral network, where each customer's aggregate revenue includes their own direct revenue plus all revenue from customers they referred (recursively). Support an insert operation that adds revenue and optionally links a referrer, and a query operation that returns the top K customers with aggregate revenue above a given threshold, sorted by revenue descending with ties broken by customer ID.

Algorithms & Data StructuresSystem DesignData Modeling
Author's notes

Took me a few minutes to really internalize the recursive part.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements and constraints, then propose a data model that supports efficient updates and queries. Discuss the trade-offs between different approaches for maintaining aggregate revenues and answering top-K queries, and outline an implementation plan with complexity analysis.

Pro tip: Mention that in a real system, you'd likely use a combination of in-memory data structures and periodic persistence, and highlight the importance of handling cycles in the referral graph to avoid infinite loops.

1. Clarify Requirements

Ask about expected scale, update/query frequency, and whether the referral graph can have cycles. Confirm that aggregate revenue is computed recursively and that ties are broken by customer ID.

2. Design Data Model

Propose storing customers in a hash map for O(1) access, with each customer having direct revenue, a list of referees, and a cached aggregate revenue. Consider maintaining a reverse index from referrer to referees for efficient updates.

3. Handle Updates

For insert, update the customer's direct revenue and, if a referrer is given, link them. Propagate the revenue change up the referral chain to update aggregate revenues, using memoization or a topological order to avoid redundant computations.

4. Implement Query

For top-K query, filter customers by aggregate revenue threshold, then sort by revenue descending and ID ascending. Use a heap for efficient top-K selection if K is small relative to the number of customers.

5. Analyze Complexity

Discuss time and space complexity for both operations. For updates, propagation cost depends on depth of referral tree; for queries, sorting is O(N log N) or O(N log K) with a heap. Mention potential optimizations like lazy propagation or segment trees.

Key Points to Mention

  • Use of hash maps for O(1) customer lookup and adjacency lists for referrals.
  • Handling cycles in the referral graph to prevent infinite loops during propagation.
  • Trade-offs between eager (update-time) and lazy (query-time) aggregation of revenue.
  • Efficient top-K selection using a min-heap when K is much smaller than N.
  • Tie-breaking by customer ID in sorting.
  • Scalability considerations: sharding, persistence, and concurrency if the system grows.

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