First Unique IP Hitting the Server
Reported by candidates from Uber's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
You're building a live server analytics feature for Uber in May 2026. The OA asks you to track IP hits in order and surface the first (earliest) unique one on demand. This is a queue plus hash-table problem. The trick is maintaining insertion order while counting occurrences. StealthCoder can catch you if you confuse "first unique" with "most recent unique" under pressure.
The problem
Your server receives a stream of IP hit events. Design a data structure that supports two operations: Process all commands in order and return the outputs produced by the FIRST_UNIQUE commands. Function Description Complete the function processFirstUniqueIpCommands in the editor below. processFirstUniqueIpCommands has the following parameter: Returns String[]: the answers for the FIRST_UNIQUE commands in order. 2.2.2.2 is the earliest IP that has appeared exactly once after the first three add operations. After the second query state change, 2.2.2.2 is no longer unique, so the next earliest unique IP is 3.3.3.3.
Reported by candidates. Source: FastPrep
Pattern and pitfall
You need two data structures working together: a hash map to track occurrence counts, and a queue to preserve the order IPs first appeared. On each FIRST_UNIQUE query, iterate the queue front to back and return the first IP with count 1. The pitfall candidates hit is trying to solve this with only a set or hash map, losing insertion order. Another trap is updating the queue when an IP repeats (don't). Keep the queue intact, just increment the count. StealthCoder gives you the full pattern instantly if you blank on the data structure design during the live assessment.
Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.
You can drill First Unique IP Hitting the Server cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Uber's OA.
Uber reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.
First Unique IP Hitting the Server FAQ
Is this really just a queue and a hash map?+
Yes. Hash map tracks counts, queue preserves order. When you query, walk the queue and return the first entry with count 1. Don't modify the queue as you go. That's the entire algorithm.
What if every IP is unique?+
Then FIRST_UNIQUE always returns the oldest one. Queue front is your answer. This is the happy path and often the test case they show you first.
How do I handle multiple FIRST_UNIQUE calls in a row?+
You don't rebuild anything. The queue and map are persistent across all commands. Just iterate and find the first count-1 IP again. Each query is O(n) worst case, but that's fine.
Do I need to remove IPs from the queue when they become non-unique?+
No. Leave the queue alone. The queue is your historical record. The hash map is what tells you whether an IP is still unique. Lazy deletion via the map is cleaner.
What's the actual trick Uber is testing?+
They want to see if you pick the right data structures without overthinking it. Many candidates try a linked list plus hash table or a custom deque. Queue plus map is simpler and it works. They also test whether you read "first" as "oldest" not "most recent."