← Uber Interview Insights

Uber·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Apr 2026

Summary

Uber SWE interview with a twist on a classic problem. Pretty short on details but the question itself is worth thinking through.

Questions Asked (1)

Q1

Given a stream of IP addresses hitting a server, find the first IP address that appears exactly once.

Algorithms & Data Structures
Author's notes

Basically a 'first unique character' problem but with IPs instead of chars.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the constraints (streaming vs. stored, memory limits, IP format) and then propose a solution using a hash map to count occurrences while tracking the order of first appearance. For a streaming scenario, maintain a doubly linked list of unique IPs and a hash map for O(1) updates, ensuring the first unique IP is always at the head.

Pro tip: Mention that you would handle IPv4 and IPv6 uniformly by treating IPs as strings or using a trie, and discuss how to scale with distributed counting if the stream is huge.

1. Clarify Requirements

Ask about the nature of the stream (real-time vs. batch), memory constraints, and whether the IP addresses are IPv4, IPv6, or both. Confirm if we need to return the first unique IP in the order of arrival.

2. Choose Data Structures

For a static list, a hash map counting frequencies and a second pass to find the first with count 1 works. For streaming, use a hash map to store nodes of a doubly linked list, where the list maintains unique IPs in order of first appearance.

3. Design the Algorithm

Initialize an empty hash map and an empty doubly linked list. For each incoming IP, if it's not in the map, add it to the tail of the list and store the node in the map; if it's already in the map, remove its node from the list (if present) and mark it as seen multiple times.

4. Handle Edge Cases

Consider cases where no unique IP exists, the stream is empty, or memory is insufficient. Discuss how to handle duplicates that appear after being removed from the list.

5. Analyze Complexity

Explain that each IP is processed in O(1) time on average, with O(U) space where U is the number of unique IPs seen so far. The first unique IP is always at the head of the list, allowing O(1) retrieval.

Key Points to Mention

  • Hash map for O(1) frequency counting or node lookup
  • Doubly linked list to maintain order of unique IPs for streaming
  • Time complexity: O(n) for n IPs, space complexity: O(U) for U unique IPs
  • Handling IPv4 and IPv6 uniformly (e.g., as strings)
  • Scalability: distributed counting or approximate algorithms for massive streams
  • Edge cases: no unique IP, empty stream, memory constraints

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