Reported April 2026
Applied Intuitiondesign

KV Store with Nested Transactions

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

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

Applied Intuition's April 2026 OA hit candidates with a nested transaction system. You're building an in-memory KV store where transactions stack, commits persist changes upward, and rollbacks erase them. The trick: each transaction level needs its own shadow copy of the store, and you have to track the stack of transaction contexts. This isn't a trick question, it's a state-machine problem. StealthCoder will catch the edge case you miss on rollback when you blank under time pressure.

The problem

Implement an in-memory key-value store that supports nested transactions. Commands are executed in order, one command per line. Supported commands are: GET returns the current value of a key, or NULL if it does not exist. ROLLBACK and COMMIT print NO TRANSACTION when there is no active transaction. Return the lines that would be printed while processing the command batch. Function Description Complete the function runNestedTransactions in the editor below. runNestedTransactions has the following parameter: Returns After setting a to 10, GET a prints that value. The inner transaction deletes a, so the first GET prints NULL. After rolling back the inner transaction, a becomes 20 again. Committing keeps that value permanent.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The pattern is design plus careful state management. You maintain a list (or stack) of transaction contexts. Each context is a dictionary of key-value pairs. On GET, search from the innermost transaction outward to the base store. On SET, write to the current transaction level only. COMMIT merges the current level into the parent, ROLLBACK discards it and pops the stack. The gotcha: candidates often flatten or merge incorrectly, losing the hierarchical semantics. When a rollback happens, you're unwinding one level of changes, not the whole store. StealthCoder, running live during the OA, will surface the exact merge logic you need if you freeze.

If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.

If this hits your live OA

You can drill KV Store with Nested Transactions 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 StealthCoder
⏵ The honest play

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

Applied Intuition 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.

KV Store with Nested Transactions FAQ

Do I need to copy the entire store on each transaction?+

No. Store only the deltas (changes made within that transaction). When you commit, merge those deltas up. When you rollback, discard them. This avoids unnecessary copying and makes the semantics clear.

What happens if I GET a key that was set in an outer transaction but deleted in an inner one?+

If the inner transaction deletes it, GET returns NULL. The deletion is local to that transaction. If you rollback the inner transaction, the outer value reappears. Always search the stack from innermost to outermost, stopping at the first hit.

How do I handle COMMIT when there are multiple nested levels?+

COMMIT merges the current (innermost) transaction's changes into the parent. It pops the current level off the stack. The parent is now active. You don't merge all the way to the base in one go.

What if ROLLBACK or COMMIT is called with no active transaction?+

Print 'NO TRANSACTION'. The problem statement is explicit on this. It's a guard clause at the start of those handlers.

Can I solve this in 30-40 minutes if I nail the stack logic?+

Yes. The algorithm is straightforward once you accept that you're managing a stack of delta-dicts, not rebasing the whole store. Implementation is ~60-80 lines if you're clean. The risk is merging logic bugs, not algorithmic complexity.

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

OA at Applied Intuition?
Invisible during screen share
Get it