← Uber Interview Insights

Uber·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Apr 2026

Summary

Uber SWE interview with a stream-processing design problem. Pretty focused session, just the one question but they dug into it pretty thoroughly.

Questions Asked (1)

Q1

You're given a stream of customer visit events (just customer IDs in arrival order). Design a data structure with two operations: record a visit for a given customer ID, and return the most recently arrived customer who has been seen exactly once so far. Return null if no such customer exists.

Algorithms & Data StructuresSystem Design
Author's notes

I started with just a hashmap for counts which was fine, but I fumbled on the 'most recent single-hit' part for a bit.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the requirements and constraints, then propose a data structure that supports O(1) record and O(1) query operations. Use a doubly linked list to maintain the order of unique customers and a hash map to track each customer's visit count and node reference, ensuring efficient updates and retrieval.

Pro tip: Discuss how your solution handles edge cases like multiple visits from the same customer and the removal of customers who are no longer unique. Also, mention how you would extend the design to support additional queries, such as the most recent customer with exactly K visits, to demonstrate scalability.

1. Clarify Requirements and Constraints

Ask about the expected scale, whether operations need to be thread-safe, and if the stream is unbounded. Confirm that 'most recently arrived' means the latest event in the stream.

2. Design the Data Structure

Propose a doubly linked list to maintain the order of unique customers, with the most recent at the tail. Use a hash map to store each customer's visit count and a pointer to their node in the list (if they are unique).

3. Define Operations

For record(customerID): update the visit count. If count becomes 1, add a new node at the tail. If count becomes 2, remove the node from the list. For query(): return the tail node's customer ID if it exists, else null.

4. Analyze Complexity and Edge Cases

Explain that both operations run in O(1) time. Discuss edge cases: customer visits multiple times, no unique customers, and memory management for removed nodes.

5. Consider Extensions and Trade-offs

Mention potential extensions like supporting K visits or handling concurrency. Discuss trade-offs between using a linked list versus other structures like a queue with lazy deletion.

Key Points to Mention

  • Use of a doubly linked list to maintain order of unique customers
  • Hash map to track visit counts and node references for O(1) updates
  • O(1) time complexity for both record and query operations
  • Handling of edge cases: multiple visits, no unique customers, and removal from list
  • Memory efficiency and potential for lazy deletion or cleanup
  • Scalability considerations for high-throughput streams

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