Assign Server Numbers by Type
Reported by candidates from Oura's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
You're looking at Oura's April 2026 OA question on server allocation. The setup is straightforward: track which server numbers are in use for each type, assign the smallest available ID on allocate, and free it up on deallocate. The trap is managing state cleanly across multiple server types without bloating your code. StealthCoder will catch the edge case you miss under time pressure.
The problem
You are given a list of server-management requests. Each request is either "allocate " or "deallocate ". Every server type has its own numbering space starting from 1. When an allocate request arrives for a type, assign the smallest positive server number that is currently unused for that type. When a deallocate request arrives, that server number becomes available again for future requests of the same type. Return the server numbers assigned by all allocate requests, in the order those allocation requests appear. Function Description Complete the function assignServerNumbersByType in the editor below. assignServerNumbersByType has the following parameter: Returns The source thread did not provide explicit numeric bounds.
Reported by candidates. Source: FastPrep
Pattern and pitfall
This is a classic state-tracking problem disguised as a system design question. You need a hash table keyed by server type, where each entry holds either a set of in-use numbers or a min-heap of available slots. The trick: when you deallocate, you're not deleting from the in-use set, you're adding back to the available pool. Most candidates build the in-use set but forget the deallocate logic creates a reusable queue. The algorithm is O(1) per operation if you use a set and a counter per type, or O(log n) per operation if you use a heap. Either works. The real cost is the mental overhead of tracking two data structures per type. That's where StealthCoder becomes your safety net on the live OA.
If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.
You can drill Assign Server Numbers by Type 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. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it.
Get StealthCoderYou've seen the question.
Make sure you actually pass Oura's OA.
Oura reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Assign Server Numbers by Type FAQ
Do I need to pre-allocate server numbers, or do they just start from 1 when the first request arrives?+
They start from 1 on demand. There's no pre-population. When you see the first allocate request for type X, the smallest unused is 1. Handle each type independently.
What if the problem doesn't give me explicit bounds on the number of requests or server types?+
Assume they're reasonable. Use a hash table for types and a set or heap per type to track numbers. Space scales with the number of active allocations, not a fixed limit.
Should I use a set of in-use numbers or a min-heap of available numbers?+
A set of in-use numbers is cleaner. On allocate, scan from 1 until you find a number not in the set, insert it, and return it. On deallocate, remove it. Simple and O(1) amortized per operation if the gap is small.
What's the most common mistake on this problem?+
Forgetting to handle deallocation properly. Candidates assign correctly but then don't track which numbers are free again. You'll miss that a deallocated server can be reassigned, leaving gaps in your output.
Can I solve this in 15-20 minutes if I know the pattern?+
Yes. Hash table per type, set of in-use numbers, and a simple counter to find the next free ID. Code it in 10 minutes, test the deallocation case, and you're done.