Reported September 2026
Nextdoordesign

In-Memory Database with Transactions and Savepoints

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

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

The constraint that kills brute force here is simple: the operations array can be long, and rescanning every transaction on every command gets ugly fast. Nextdoor's In-Memory Database with Transactions and Savepoints showed up in reports from September 2026, and it's a design simulation, not a trick question. You process BEGIN, SET, GET, COUNT, ROLLBACK and COMMIT left to right and return one string per operation. If you've got an OA invite, expect to spend your time on edge cases, not algorithms. StealthCoder is the safety net if you blank mid-assessment, but the core idea fits in your head tonight.

The problem

Implement an in-memory database with a permanent store and a stack of active transactions. Process the finite array operations from left to right and return one output string for every operation.
Each operation has one of these forms:
BEGIN: push an empty transaction and return OK.
SET key value: write into the newest active transaction and return OK. If no transaction is active, do not change state and return ERROR.
GET key: search active transactions from newest to oldest, then the permanent store. Return the first value found, or NOT_FOUND.
COUNT: return the number of keys in the permanent store as a decimal string. Uncommitted keys do not count.
ROLLBACK: discard only the newest active transaction and return OK. If no transaction is active, return ERROR.
COMMIT: apply all active transactions to the permanent store from oldest to newest, clear the transaction stack, and return OK. If no transaction is active, return ERROR.
The database starts with an empty permanent store and no active transaction.

Function
runDatabaseSimulator(operations: String[]) → String[]

Examples
Example 1
operations = ["COUNT","BEGIN","SET a 1","GET a","COUNT","COMMIT","COUNT","GET a"]
return = ["0","OK","OK","1","0","OK","1","1"]
The uncommitted key is readable through GET but does not affect COUNT. After COMMIT, it becomes permanent.
Example 2
operations = ["BEGIN","SET x outer","BEGIN","SET x inner","GET x","ROLLBACK","GET x","COMMIT","GET x"]
return = ["OK","OK","OK","OK","inner","OK","outer","OK","outer"]
The inner value shadows the outer value until the inner transaction is rolled back. Committing then makes the outer value permanent.

Constraints
Every operation follows one of the documented command forms.
Keys and values are non-empty and contain no whitespace.
A stored value is never the reserved result token NOT_FOUND.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The structure is a permanent hash map plus a stack of hash maps, one per transaction. SET writes to the top map. GET walks the stack from newest to oldest, then checks the permanent map. COMMIT merges maps from oldest to newest into the permanent store, so newer values overwrite older ones, then clears the stack. ROLLBACK just pops the top. COUNT only looks at the permanent store, which is the part people fumble because uncommitted keys must not count. The common pitfalls are returning ERROR correctly when no transaction is active for SET, ROLLBACK and COMMIT, and applying commits in the wrong order. Parse each line by splitting on spaces. Nothing here is hard, but one wrong branch fails hidden tests. If you freeze during the live OA, StealthCoder can give you a working solution while you stay calm and verify the edge cases.

If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.

If this hits your live OA

You can drill In-Memory Database with Transactions and Savepoints 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 passed his OA cold and still thinks the filter is broken.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

Nextdoor reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.

In-Memory Database with Transactions and Savepoints FAQ

How hard is the Nextdoor in-memory database OA question really?+

It's easy to medium. There's no clever algorithm, just careful state handling. A hash map plus a stack of hash maps covers everything. Most failures come from missed edge cases like ERROR returns with no active transaction, or COUNT including uncommitted keys.

What's the trick to get COMMIT right?+

Iterate the transaction stack from oldest to newest and write each key and value into the permanent map. Later transactions overwrite earlier ones, which gives the correct final value. Then clear the whole stack. Don't commit only the top transaction, that's the classic mistake.

Why does COUNT trip people up?+

COUNT only reports keys in the permanent store. A SET inside a transaction is visible to GET but not to COUNT until COMMIT. Example 1 shows this: COUNT returns 0 after SET a 1 inside a transaction, then 1 after COMMIT.

Is this design-style simulation pattern still asked?+

Yes. Nextdoor candidates reported it in September 2026. Command-processing simulations with stacks and maps are a steady OA format because they test clean state management instead of memorized algorithms.

How do I prepare in 48 hours?+

Write this exact class once from scratch. Handle all six commands, test both examples, then add cases for empty stacks, nested BEGIN with ROLLBACK, and overwriting the same key across transactions. Pay attention to input parsing, since SET has three tokens and the others have fewer.

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

OA at Nextdoor?
Invisible during screen share
Get it