← Uber Interview Insights

Uber·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
May 2026Remote

Summary

Uber SWE interview, coding round. One meaty graph/union-find problem with a bunch of follow-ups tacked on at the end. The core question wasn't too bad but the follow-ups came fast and I wasn't fully ready for the stream processing one.

Questions Asked (5)

Q1

Given a list of user IDs and a chronological log of ride-sharing events (each event records two users who shared a ride), find the earliest timestamp at which all users become part of a single connected component. Return -1 if they never all connect.

Algorithms & Data Structures
Author's notes

Classic union-find setup once you see it, but I spent a minute fumbling around thinking about BFS before the structure clicked.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the problem as dynamic connectivity: process events in chronological order, using a union-find (disjoint set) data structure to merge the two users in each event. After each union, check if the number of connected components has dropped to 1; if so, return the current event's timestamp. If all events are processed without reaching a single component, return -1.

Pro tip: Mention that union-find with union by rank and path compression gives near-constant time per operation, making the solution O(E α(N)) which is optimal. Also, clarify that you assume the log is sorted by timestamp; if not, sort it first, and handle edge cases like empty user list or already connected users.

1. Clarify input and assumptions

Confirm that the log is sorted chronologically, that each event has a timestamp and two user IDs, and that all user IDs are from the given list. Ask about edge cases: empty list, single user, duplicate events, or events with users not in the list.

2. Choose data structure

Select union-find (disjoint set) to efficiently track connected components. Initialize each user as its own parent and maintain a count of components (starting at N).

3. Process events in order

Iterate through the log. For each event, union the two users. If the union merges two different components, decrement the component count. After each union, if component count equals 1, return the current timestamp.

4. Handle termination

If the loop finishes without the component count reaching 1, return -1. Also, if the initial component count is already 1 (only one user), return the earliest timestamp or 0 depending on problem definition.

5. Analyze complexity and edge cases

State time complexity O(E α(N)) and space O(N). Discuss edge cases: no events, disconnected users, duplicate unions, and timestamps with ties.

Key Points to Mention

  • Union-Find (Disjoint Set Union) with path compression and union by rank/size
  • Dynamic connectivity and component counting
  • Time complexity O(E α(N)) and space O(N)
  • Handling unsorted logs (sort first) and timestamp ties
  • Edge cases: empty user list, single user, no events, never fully connected
  • Early termination when component count reaches 1

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

Q2

The log contains multiple event types. How would you modify your solution to only create connections for specific event types?

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

Easy filter, just check the event type string before calling union.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the current solution's architecture and how event types are represented. Then, propose a filtering mechanism that can be applied at the appropriate stage, considering trade-offs between performance, maintainability, and scalability. Finally, discuss how to make the filter configurable and testable.

Pro tip: Mention that filtering early in the pipeline (e.g., at the source or during parsing) can reduce downstream processing and memory usage, but may require changes to the ingestion layer. Also, consider using a strategy pattern or a set of allowed event types to make the solution extensible.

1. Clarify requirements and current design

Ask clarifying questions about which event types to include, whether the list is static or dynamic, and how the current solution processes events. Understand the data flow and where connections are created.

2. Identify filtering point

Determine the best stage to filter events: at ingestion, during parsing, or before connection creation. Consider performance implications and ease of modification.

3. Design filtering mechanism

Propose a configurable filter, such as a set of allowed event types or a predicate function. Discuss how to pass this configuration and apply it efficiently.

4. Discuss trade-offs and alternatives

Compare filtering early vs. late, and consider scalability, maintainability, and potential impact on existing code. Mention if filtering can be done in parallel or with minimal overhead.

5. Outline testing and extensibility

Explain how to test the filter with unit tests and how to extend it for new event types without major refactoring, e.g., using dependency injection or configuration files.

Key Points to Mention

  • Event type representation (e.g., string, enum) and how to compare efficiently
  • Filtering at ingestion vs. during processing: impact on performance and resource usage
  • Configurability: using a set, list, or predicate to specify allowed event types
  • Trade-offs: early filtering reduces load but may require changes to data sources; late filtering is easier but less efficient
  • Scalability: handling high-volume logs and ensuring the filter doesn't become a bottleneck
  • Testing: unit tests for filter logic and integration tests to ensure only desired connections are created

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

Q3

What if the log entries are not sorted by timestamp?

Algorithms & Data Structures
Author's notes

Sort first, then run the same logic.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the problem constraints: are we dealing with a one-time sort or a streaming scenario? Then, discuss the trade-offs between sorting upfront (O(n log n)) versus using a min-heap for streaming (O(n log k) for top k) or bucketing if timestamps have limited range. Finally, emphasize that the choice depends on memory, latency, and whether we need all logs sorted or just the latest.

Pro tip: Mention that in real systems like Uber, logs are often ingested out-of-order due to network delays, so you might need a watermark or allowed lateness window to handle late data. This shows you understand distributed systems challenges beyond pure algorithms.

1. Clarify requirements

Ask whether we need to sort all logs, find the latest N, or process in a streaming fashion. Also check if timestamps are unique and if memory is constrained.

2. Consider sorting approaches

If all logs fit in memory, use comparison sort (e.g., merge sort) for O(n log n). If not, use external sorting (e.g., merge sort with chunks) or distributed sorting (e.g., MapReduce).

3. Explore heap-based solutions

For finding the latest k logs, use a min-heap of size k to keep the k largest timestamps, giving O(n log k) time and O(k) space. This is efficient for streaming or large n.

4. Consider bucketing or counting sort

If timestamps are integers within a known range, use bucketing (e.g., array of lists) to achieve O(n) time. This is common in log processing where timestamps are epoch seconds.

5. Discuss trade-offs and edge cases

Compare time/space complexity, stability, and suitability for streaming. Mention handling duplicate timestamps, late data, and memory limits.

Key Points to Mention

  • Time and space complexity of sorting vs. heap vs. bucketing
  • Streaming scenario: use min-heap for top k or sliding window
  • External sorting for data that doesn't fit in memory
  • Bucketing/counting sort when timestamp range is small
  • Handling duplicate timestamps and stability
  • Real-world considerations: out-of-order logs, watermarks, and allowed lateness

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

Q4

What is the time complexity of your approach?

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

I said O(n * alpha(m)) where n is events and alpha is the inverse Ackermann from union-find, plus O(m log m) if you need to sort.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clearly state the time complexity using Big O notation, then explain how you derived it by analyzing each part of your algorithm. Discuss any trade-offs between time and space complexity, and mention if the complexity is optimal for the problem.

Pro tip: Always relate the complexity to the problem constraints (e.g., input size) and explain why your approach is efficient enough for the expected scale, especially in a company like Uber where scalability matters.

1. State the Complexity

Begin by clearly stating the time complexity in Big O notation, e.g., O(n log n).

2. Break Down the Analysis

Explain how you arrived at that complexity by analyzing each part of your algorithm (e.g., loops, recursive calls, operations).

3. Discuss Trade-offs

Mention any trade-offs between time and space complexity, and why you chose this approach over alternatives.

4. Relate to Constraints

Connect the complexity to the problem's input size and constraints, explaining why it's acceptable or optimal.

5. Consider Optimizations

If applicable, briefly mention potential optimizations or why further optimization isn't necessary.

Key Points to Mention

  • Big O notation and its meaning (worst-case, average-case)
  • Step-by-step derivation of the complexity from the code
  • Space complexity and trade-offs with time
  • Comparison with alternative approaches and their complexities
  • Relevance to problem constraints and scalability
  • Potential optimizations or why the current complexity is optimal

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

Q5

How would your approach change if the log is extremely large and has to be processed as a stream, without loading it all into memory?

System DesignTechnical Trade-offs
Author's notes

This is where I stumbled a bit.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Acknowledge that streaming requires a shift from in-memory processing to incremental, bounded-memory techniques. Outline a design that reads the log in chunks, processes each chunk independently, and aggregates results, while addressing challenges like ordering, state management, and fault tolerance.

Pro tip: Emphasize that streaming isn't just about memory; it's about designing for throughput, latency, and failure recovery. Mention that you'd consider using a distributed stream processing framework like Apache Flink or Kafka Streams to handle scale and exactly-once semantics.

1. Clarify requirements and constraints

Ask about log size, format, processing goals (e.g., filtering, aggregation), latency requirements, and available resources. This ensures the solution fits the actual needs.

2. Choose a streaming architecture

Decide between a simple line-by-line reader, a producer-consumer setup, or a full stream processing framework. Consider factors like scalability, fault tolerance, and ease of development.

3. Design for bounded memory and state

Use techniques like windowing, incremental aggregation, and external state stores (e.g., Redis, RocksDB) to avoid holding all data in memory. Handle out-of-order events with watermarks if needed.

4. Address fault tolerance and exactly-once processing

Implement checkpointing, idempotent operations, or transactional sinks to ensure correctness in case of failures. Discuss trade-offs between at-least-once and exactly-once semantics.

5. Optimize for performance and scalability

Consider partitioning, parallel processing, backpressure handling, and efficient serialization. Mention monitoring and tuning as part of the lifecycle.

Key Points to Mention

  • Bounded memory techniques: chunking, windowing, and incremental aggregation
  • Stream processing frameworks: Apache Flink, Kafka Streams, Spark Streaming
  • State management: external stores, checkpointing, and fault tolerance
  • Exactly-once vs at-least-once semantics and their trade-offs
  • Backpressure and flow control to handle varying input rates
  • Partitioning and parallel processing for scalability

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