← Uber Interview Insights

Uber·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
May 2026

Summary

Uber software engineer interview with a data structures problem centered on streaming IP hits. The follow-up about scaling to billions of records is where things got interesting and where I probably lost some points.

Questions Asked (2)

Q1

Design a component that processes a stream of server hit records (each containing an IP address) and supports two operations: recording a new hit from an IP, and returning the earliest IP that has appeared exactly once so far.

Algorithms & Data StructuresSystem Design
Author's notes

The core idea clicked pretty fast.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify requirements first: the stream is append-only, and we need to return the earliest IP that has appeared exactly once so far. Then propose a data structure that tracks counts and maintains order, such as a doubly linked list of unique IPs combined with a hash map from IP to its node and count, achieving O(1) per operation.

Pro tip: Mention that the solution must handle duplicates correctly: when an IP's count goes from 1 to 2, it should be removed from the unique list, and if it later appears again, it should not be re-added. This shows attention to edge cases and real-world stream processing.

1. Clarify requirements and constraints

Ask about the definition of 'earliest' (first occurrence time), whether the stream is unbounded, and if we need to handle deletions or updates. Confirm that we only need to support adding hits and querying the earliest unique IP.

2. Design the data structures

Propose a hash map to store IP counts and a doubly linked list to maintain the order of IPs that currently have count 1. Each node in the list represents a unique IP, and the map stores a pointer to the node for O(1) removal.

3. Define the record operation

When a new hit arrives, increment its count in the map. If the count becomes 1, append a new node to the tail of the list. If the count becomes 2, remove the corresponding node from the list and update the map to indicate it's no longer unique.

4. Define the query operation

To return the earliest unique IP, simply return the head of the list (if it exists). This gives O(1) time.

5. Analyze complexity and discuss trade-offs

Explain that both operations run in O(1) time and O(n) space, where n is the number of distinct IPs seen. Discuss potential memory concerns for unbounded streams and possible optimizations like approximate counting or time-based eviction.

Key Points to Mention

  • Use of a hash map to track counts and a doubly linked list to maintain order of unique IPs.
  • O(1) time complexity for both record and query operations.
  • Handling duplicates: when an IP appears more than once, it must be removed from the unique list and not re-added.
  • Edge cases: empty stream, all IPs duplicated, and memory management for unbounded streams.
  • Alternative approaches like using a min-heap with lazy deletion, and why the linked list is more efficient.
  • Real-world considerations: concurrency, distributed processing, and persistence if the stream is large-scale.

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

Q2

Follow-up: how would you scale this solution to handle millions or billions of hit records? Walk through memory usage, throughput, and the trade-offs between exact and approximate results.

System DesignTechnical Trade-offs
Author's notes

This is where I fumbled.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the scale and requirements (e.g., data volume, query patterns, latency SLAs) and then propose a distributed architecture that partitions data across nodes, using approximate data structures like HyperLogLog or Count-Min Sketch to reduce memory footprint. Discuss trade-offs between exact and approximate results in terms of accuracy, memory, and throughput, and how to handle failures and consistency.

Pro tip: Quantify the impact: for example, mention that HyperLogLog can estimate cardinality with 2% error using only 1.5 KB per counter, which is orders of magnitude less than exact sets. This shows you understand the practical implications of design choices.

1. Clarify Requirements and Scale

Ask about data volume (millions vs billions), read/write patterns, latency requirements, and acceptable error margins. This ensures your solution aligns with business needs.

2. Design Distributed Architecture

Propose partitioning data across multiple nodes (e.g., sharding by user ID or time) and using a distributed system like Apache Spark or Flink for processing. Discuss replication and fault tolerance.

3. Choose Data Structures and Algorithms

For exact results, consider distributed hash tables or sorted sets, but highlight memory challenges. For approximate results, introduce probabilistic data structures like HyperLogLog, Count-Min Sketch, or Bloom filters, explaining their memory and accuracy trade-offs.

4. Analyze Memory and Throughput

Estimate memory usage per node and overall, and calculate throughput based on partitioning and parallelism. Compare exact vs approximate in terms of resource consumption and performance.

5. Discuss Trade-offs and Mitigations

Summarize trade-offs: exact results offer precision but high memory and lower throughput; approximate results save resources but introduce error. Suggest hybrid approaches or fallback mechanisms if needed.

Key Points to Mention

  • Sharding and partitioning strategies (e.g., consistent hashing, range partitioning) to distribute load.
  • Probabilistic data structures: HyperLogLog for cardinality, Count-Min Sketch for frequency, Bloom filters for membership.
  • Memory vs accuracy trade-off: exact structures require O(n) memory, while approximate use O(log log n) or constant space with bounded error.
  • Throughput considerations: horizontal scaling, parallel processing, and avoiding single points of contention.
  • Consistency and fault tolerance: replication, eventual consistency, and handling node failures.
  • Real-world examples: how Uber might use approximate counting for unique riders or trips per city.

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