← Uber Interview Insights

Uber·Software Engineer·Onsite - System Design / Architecture·Senior

SeniorPrefer not to say
May 2026

Summary

Uber system design round for a software engineer role. The problem was a custom customer-revenue tracking system with some tricky query semantics, and most of the time went into debating data structures and their tradeoffs.

Questions Asked (1)

Q1

Design a customer-revenue system with three operations: add a new customer with a starting revenue and return their id; add a customer via referral where the referrer's revenue also gets bumped by the new customer's revenue; and query the k customers with the smallest revenues among those strictly above a given threshold. Discuss suitable data structures and the complexity of each operation.

Algorithms & Data StructuresSystem DesignTechnical Trade-offs
Author's notes

The add operations are straightforward enough but the referral one trips you up because updating the referrer's revenue means their position in any sorted structure changes.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements and constraints, such as the expected number of operations, the range of revenues, and whether the query threshold is inclusive. Then propose a data structure that supports efficient insertion, update, and threshold-based top-k queries, discussing trade-offs between different approaches. Finally, analyze the time and space complexity of each operation and consider optimizations for the given constraints.

Pro tip: Mention that the referral operation requires updating the referrer's revenue, which may change its position in the ordering; thus, the data structure must support efficient updates. Also, consider using a balanced BST augmented with subtree sizes to handle top-k queries efficiently.

1. Clarify Requirements and Constraints

Ask about the expected number of operations, the range of revenue values, whether revenues can be negative, and if the threshold is inclusive. Also, clarify if the query should return the customers in sorted order or just any k customers.

2. Choose Data Structures

Propose using a balanced binary search tree (e.g., AVL or Red-Black tree) where each node stores a customer and is keyed by revenue, augmented with subtree sizes to support order statistics. Alternatively, consider a Fenwick tree over compressed revenue values if revenues are bounded.

3. Design Operations

For addCustomer: insert a new node with the given revenue and return its id. For addReferral: insert the new customer and update the referrer's revenue by adding the new customer's revenue, which may require deleting and reinserting the referrer's node. For query: find the first node with revenue > threshold, then retrieve the next k nodes in order.

4. Analyze Complexity

For a balanced BST with subtree sizes, each operation takes O(log n) time on average, where n is the number of customers. The query operation takes O(log n + k) time. Space complexity is O(n). If using a Fenwick tree, operations are O(log M) where M is the number of distinct revenue values.

5. Discuss Trade-offs and Optimizations

Compare the BST approach with alternatives like a skip list or a segment tree. Discuss how to handle duplicate revenues (e.g., by storing a list of customers per revenue or using a tie-breaker). Mention that if k is small, a heap-based approach might be simpler but less efficient for arbitrary k.

Key Points to Mention

  • Use of a balanced BST augmented with subtree sizes for order statistics.
  • Handling updates to referrer's revenue: delete and reinsert or update in place if the BST supports it.
  • Threshold query: find the successor of the threshold and then perform an in-order traversal for k elements.
  • Complexity: O(log n) for insert and update, O(log n + k) for query, O(n) space.
  • Alternative: Fenwick tree with coordinate compression if revenue values are bounded and updates are frequent.
  • Edge cases: duplicate revenues, threshold larger than all revenues, k larger than available customers.

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