← Uber Interview Insights

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

SeniorPrefer not to say
Jul 2026

Summary

System design round for an ML Engineer role at Uber. The whole thing was one big design problem about a game-room leaderboard, which sounds simple but ended up going pretty deep into heap internals and complexity tradeoffs.

Questions Asked (1)

Q1

Design a data structure for a sequence of rooms where players complete tasks in order. Support addPlayer, recordTask (with points), moveToNextRoom, getPlayerState, and topK (top K players by total score). Discuss how you'd handle duplicate entries in a heap-based leaderboard, analyze time and space complexity for each operation, and justify your design.

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

This took me a while to decompose.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements and constraints, then propose a hybrid data structure combining a doubly linked list for room progression and a hash map for player states, with a heap-based leaderboard for topK queries. Discuss handling duplicate scores in the heap by storing (score, playerId) tuples and using a lazy deletion strategy for updates.

Pro tip: Emphasize the trade-offs between update efficiency and query efficiency, and mention that for ML applications, you might need to support approximate topK with sketches like Count-Min Sketch for scalability.

1. Clarify Requirements and Constraints

Ask about expected number of players, frequency of operations, and whether topK needs to be exact or approximate. This guides data structure choices.

2. Design Core Data Structures

Use a doubly linked list for rooms to allow O(1) moveToNextRoom, a hash map for player states (current room, total score), and a max-heap for leaderboard.

3. Handle Duplicates in Heap

Store entries as (score, playerId) to avoid ambiguity. For updates, use lazy deletion: push new entry and mark old as invalid, cleaning up when popped.

4. Analyze Complexity

For each operation: addPlayer O(1), recordTask O(log N) due to heap update, moveToNextRoom O(1), getPlayerState O(1), topK O(K log N) or O(K) with heapify.

5. Justify and Discuss Trade-offs

Explain why this design balances update and query performance, and mention alternatives like balanced BST or skip list for different trade-offs.

Key Points to Mention

  • Use of doubly linked list for rooms to support O(1) moveToNextRoom.
  • Hash map for player states to achieve O(1) getPlayerState and recordTask updates.
  • Heap-based leaderboard with (score, playerId) tuples to handle duplicates.
  • Lazy deletion strategy for heap updates to avoid O(N) removal.
  • Time complexity: addPlayer O(1), recordTask O(log N), moveToNextRoom O(1), getPlayerState O(1), topK O(K log N).
  • Space complexity: O(N + R) where N is players and R is rooms.

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