← Uber Interview Insights

Uber·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
May 2026

Summary

Uber SWE interview with a data structure design problem around customer revenue and referral tracking. Pretty involved for a coding round, felt more like a mini system design embedded in a DSA question.

Questions Asked (1)

Q1

Design a data structure that tracks customer revenue and referral credit. It needs to support inserting new customers (with or without a referrer), where inserting with a referrer also bumps the referrer's total revenue. There's also a query that returns up to K customer IDs whose total revenue meets a minimum threshold, ordered by smallest revenue first.

Algorithms & Data StructuresData ModelingSystem Design
Author's notes

The insert operations are straightforward enough but the getLowestK query is where things get interesting.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements and constraints, then propose a data structure that efficiently supports insertions with referrer updates and threshold-based queries. A balanced BST or a heap combined with a hash map can work, but discuss trade-offs and potential optimizations like bucketing or indexing by revenue.

Pro tip: Demonstrate awareness of real-world constraints: mention that in a production system, you'd consider concurrency, persistence, and scalability, and possibly use a database with appropriate indexes rather than an in-memory structure.

1. Clarify Requirements

Ask about expected data volume, query frequency, K value, threshold range, and whether updates are frequent. Confirm if customer IDs are unique and if revenue can be negative.

2. Choose Data Structures

Propose a hash map for O(1) customer lookup and a balanced BST (or skip list) keyed by revenue for ordered queries. Alternatively, consider a min-heap for top-K queries if K is small, but note limitations for threshold queries.

3. Design Operations

For insert: add customer to hash map and BST; if referrer exists, update referrer's revenue by removing and reinserting in BST. For query: traverse BST in-order starting from threshold, collecting up to K customers.

4. Analyze Complexity

Insert: O(log n) for BST update, O(1) for hash map. Query: O(log n + K) for BST traversal. Discuss potential optimizations like caching frequent queries or using a Fenwick tree for prefix sums if revenue updates are additive.

5. Discuss Trade-offs and Extensions

Compare with alternative approaches (e.g., sorted array, heap) and mention scalability considerations like sharding, concurrency control, and persistence for a production system.

Key Points to Mention

  • Use a hash map for O(1) customer lookup by ID.
  • Use a balanced BST (e.g., Red-Black Tree) or skip list to maintain customers ordered by revenue.
  • For referrer updates, remove and reinsert the referrer in the BST to maintain order.
  • Query returns up to K customers with revenue >= threshold, ordered by smallest revenue first; use in-order traversal starting from threshold.
  • Time complexity: O(log n) per insert/update, O(log n + K) per query.
  • Consider concurrency, persistence, and scalability for production; possibly use a database with indexes.

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