Reported December 2022
Old Missionhash table

Implement an Unordered Map

Reported by candidates from Old Mission's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Old Mission OA. Under 2s to a working solution.
Founder's read

Old Mission reportedly sent this one in December 2022, and it's a classic hash table build from scratch. You're told no built-in map, dictionary, or hash-table type, and up to 200000 operations. That input size is the whole point: a linear scan per get will time out, so you need hashing with real collision handling. The function is runUnorderedMap, and it returns only the get results in order. If you blank on the bucket details during the live OA, StealthCoder is the safety net that reads the problem and hands you a working structure. Still, it's a short build you can learn tonight.

The problem

Implement an integer key-value map without using a language-provided map, dictionary, or hash-table type.
Process the operations in order:
put with arguments [key, value] inserts the key or replaces its current value.
get with arguments [key] appends the current value to the result, or -1 when the key is absent.
remove with arguments [key] erases the key when it is present and otherwise does nothing.
Return the results of the get operations in their original order.
Your implementation should use hashing, resolve collisions correctly, and provide expected constant-time operations.

Function
runUnorderedMap(operations: String[], arguments: int[][]) → int[]

Examples
Example 1
operations = ["put","put","get","put","get","remove","get"]
arguments = [[1,10],[2,20],[1],[1,15],[1],[2],[2]]
return = [10,15,-1]
The first get(1) returns 10. Updating key 1 makes the next lookup return 15. After removing key 2, its lookup returns -1.
Example 2
operations = ["get","put","put","get","remove","get"]
arguments = [[-5],[-5,7],[11,4],[-5],[-5],[-5]]
return = [-1,7,-1]
Negative keys are valid. The missing key first produces -1, then stores 7, and becomes absent again after removal.

Constraints
1 <= operations.length == arguments.length <= 200000
Each operation is put, get, or remove.
A put argument has length 2; the other argument arrays have length 1.
-10^9 <= key <= 10^9
0 <= value <= 10^9
Do not use a built-in map, dictionary, or hash-table implementation.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is a fixed array of buckets, each holding a chain of key-value nodes. Hash the key with a modulo, and make it safe for negatives. Keys go down to -10^9, so a plain key % size can go negative in some languages. Use ((key % n) + n) % n. Put walks the chain, updates if the key exists, otherwise inserts. Get walks the chain and returns -1 if missing. Remove unlinks the node. The common pitfall is forgetting that put on an existing key must replace the value, not add a duplicate. Another is picking a tiny bucket count, which makes chains long and kills the constant-time promise. Pick something like a prime near 100003 or resize when load gets high. Only append results for get, not put or remove. StealthCoder is your hedge in the live OA if the pointer handling in the chain deletion trips you up.

Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.

If this hits your live OA

You can drill Implement an Unordered Map 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 for the candidate who got the OA invite this morning and has 72 hours, not six months.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as design hashmap. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass Old Mission's OA.

Old Mission reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Implement an Unordered Map FAQ

How hard is the Old Mission unordered map problem really?+

Easy to medium. There's no clever algorithm, just careful implementation. The risk is bugs in chain removal and negative key hashing, not the idea. If you've written a linked list delete before, you can finish this quickly.

What's the trick to passing the 200000 operations limit?+

Use a large enough bucket array, around 100003 or so, with separate chaining. Average chain length stays tiny, so each put, get, and remove is expected constant time. A single list scan per operation is what fails.

How do I handle negative keys in the hash?+

Keys range from -10^9 to 10^9. Compute the index as ((key % size) + size) % size so it's never negative. Example 2 in the problem uses -5, so test that case before submitting.

Can I use an array indexed by key instead?+

No. The key range spans about 2 billion values, which is far too big for a direct array, and the problem demands hashing with collision resolution. Use buckets with chaining or open addressing instead.

How do I prepare for this in 48 hours?+

Write it once from memory: node class, bucket array, hash function, put, get, remove. Then run both examples by hand. Pay attention to updating an existing key and returning only get results in order.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Old Mission.

OA at Old Mission?
Invisible during screen share
Get it