First Unique Number
A medium-tier problem at 56% community acceptance, tagged with Array, Hash Table, Design. Reported in interviews at Uber and 0 others.
First Unique Number is a medium-difficulty problem that asks you to identify the first element that appears only once in a stream of incoming data. Uber has asked this one repeatedly. The trap is thinking you can solve it with a single pass or a naive frequency counter. You can't. The problem demands that you track both occurrence counts and insertion order simultaneously, which means you need to design a data structure that handles two competing concerns at once. Most candidates blank on the design phase and waste time on an approach that works for static arrays but fails on streaming input.
Companies that ask "First Unique Number"
First Unique Number is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built because the OA filter rejects engineers who'd pass the on-site. That's a broken filter. This is the workaround.
Get StealthCoderThe core trick is combining a hash table for frequency tracking with a queue or linked list to preserve insertion order. Your hash table tells you which elements appear once, but the queue tells you which one came first. The common mistake is using just a frequency map, then iterating through it later, that loses the temporal dimension. Another trap is building a doubly-linked list from scratch when you could use a deque or queue to sidestep pointer management. The streaming nature means you can't sort or rearrange after the fact. During a live assessment, if you freeze on whether to use a queue or a set, or how to handle the deque pointers, StealthCoder surfaces the exact structure in seconds, invisible to the proctor, so you don't blow 20 minutes on implementation details.
Pattern tags
You know the problem.
Make sure you actually pass it.
First Unique Number recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built because the OA filter rejects engineers who'd pass the on-site. That's a broken filter. This is the workaround. Works on HackerRank, CodeSignal, CoderPad, and Karat.
First Unique Number interview FAQ
Is this really asked at FAANG?+
Uber has asked it. The acceptance rate is moderate, around 56 percent, meaning roughly half the candidates who attempt it pass. It's a system-design-flavored algorithmic problem, so it appears in companies that care about building robust data structures under constraints.
What's the trick to not failing on streaming input?+
You must track insertion order, not just frequencies. A hash table alone fails because you can't know which unique element came first. Pair it with a queue or deque that preserves the order you saw elements. When an element's count changes, update the hash table and queue state together.
Can I use an array for this instead of a queue?+
Not efficiently. If you use an array and scan it every time to find the first unique element, you get O(n) lookup per query. A queue or deque with a hash table gives you O(1) operations. For streaming data, O(1) is non-negotiable.
How does this relate to the other data structure design problems?+
It's in the same family as LRU Cache and designing custom data structures. The key theme: you're forced to combine two or more standard structures to meet conflicting requirements. Here, frequency tracking and order preservation are the conflict.
What language should I use to avoid pointer bugs?+
Python or JavaScript make deque and queue operations simpler and less error-prone than C++ or Java. The problem isn't language-specific, but a language with built-in deque support saves you from off-by-one errors on pointers.
Want the actual problem statement? View "First Unique Number" on LeetCode →