Mutable Record Store with Error Results
Reported by candidates from Squarepoint Capital's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The data structure carrying this one is a plain hash map, and Squarepoint Capital's September 2026 OA wants you to use it cleanly. The question is a mutable record store: INSERT, UPDATE, REMOVE, GET, each returning OK, ERROR, or a value. Nothing here is hard algorithmically. The risk is sloppy edge handling when you're under the clock. If the assessment feels easy, that's the trap, because one wrong branch on a duplicate insert fails hidden tests. StealthCoder sits invisibly on your screen as a safety net if you blank mid-OA, but this one is mostly about being careful.
The problem
Process commands over string records keyed by id: INSERT id value creates a missing record. UPDATE id value changes an existing record. REMOVE id deletes an existing record. GET id reads an existing value. Every successful mutation emits OK. A duplicate insert or any missing-id update, remove, or get emits ERROR. GET otherwise emits the value. Return all results in command order. Function recordStore(operations: String[]) → String[] Examples Example 1 operations = ["INSERT a one","GET a","UPDATE a two","GET a","REMOVE a","GET a"] return = ["OK","one","OK","two","OK","ERROR"] The record moves through insert, update, removal, and missing read. Example 2 operations = ["INSERT x 1","INSERT x 2","GET x"] return = ["OK","ERROR","1"] A duplicate insert does not overwrite. Example 3 operations = ["UPDATE q 9","REMOVE q"] return = ["ERROR","ERROR"] Both operations require an existing record. Constraints 1 <= operations.length <= 10^5. Ids and values are nonempty strings without spaces. Commands are valid and use only the four documented operations.
Reported by candidates. Source: FastPrep
Pattern and pitfall
Use a hash map from id to value. Parse each command by splitting on spaces. INSERT: if the id exists, emit ERROR and leave the old value alone, else store it and emit OK. UPDATE: if the id is missing, ERROR, else overwrite and OK. REMOVE: if missing, ERROR, else delete and OK. GET: if missing, ERROR, else emit the stored value. Every operation is O(1) average, so 10^5 commands is trivial. The common pitfall is the duplicate insert overwriting the value, which Example 2 specifically calls out. Another is checking truthiness of the value instead of key presence, which is risky if you use a language where empty or falsy values confuse lookups. Always test with containsKey or its equivalent. Append results to a list in order and return it. If you freeze on parsing or the branch logic during the live OA, StealthCoder can hand you the solution so you can verify and move on.
Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.
You can drill Mutable Record Store with Error Results 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 StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Squarepoint Capital's OA.
Squarepoint Capital 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.
Mutable Record Store with Error Results FAQ
How hard is the Squarepoint Capital record store question really?+
Easy on algorithm, easy to fumble on details. It's a hash map with four commands. Candidates lose points on the duplicate insert case and on missing-id handling, not on complexity. Read the examples twice and you're fine.
What's the trick to this problem?+
There isn't a clever one. Use a hash map keyed by id, check key presence before every operation, and never overwrite on INSERT when the id exists. Return results in command order using a list.
Do I need to worry about performance with 10^5 operations?+
No. Hash map insert, lookup, update, and delete are O(1) on average, so the whole thing is O(n). Just avoid anything quadratic like scanning a list of records for each command.
How should I parse each command?+
Split the string on spaces. The first token is the command, the second is the id, and the third, when present, is the value. Since ids and values have no spaces and commands are valid, you don't need defensive parsing.
How do I prepare for this in 48 hours?+
Write this one from scratch once in your main language, then run the three examples plus a few edge cases: remove then reinsert, update after remove, and repeated gets. Also review similar map-simulation problems so the structure feels automatic.