Free beta: free to use with daily limits while we build. Join the waitlist for founding-member pricing at launch. Join the waitlist

Sign up free

Figma interview question

Build an in-memory key-value store with nested transactions and atomic batches

Company:
Figma
Round:
Technical
Type:
Coding
Difficulty:
Medium
Reported:
June 2, 2026

Problem

Implement an in-memory key-value store with:

  • set(key, value), get(key) (returns None if missing), and delete(key) (returns True if the key existed).
  • begin(): start a transaction; transactions can be nested.
  • rollback(): undo all changes made in the innermost open transaction; return False if no transaction is open.
  • commit(): close the innermost transaction, keeping its changes (an enclosing transaction can still roll them back); return False if none is open.
  • apply_batch(ops): apply a list of operations atomically. Operations are ("set", key, value) or ("delete", key). If any operation is invalid (unknown type, or deleting a missing key), none of the batch takes effect and the method returns False; otherwise True.

Example 1

Input: set("a",10), begin(), set("a",20), get("a"), begin(), delete("a"), get("a"), rollback(), get("a"), commit(), get("a"), rollback()
Output: 20, None, 20, 20, False

The inner rollback restores the value 20; after the outer commit there is no open transaction.

Constraints

  • Up to 10^5 operations; nesting depth up to 10^3.
  • Keys and values are strings or integers.

Reported by candidates or drawn from publicly available sources, and rewritten in our own words. Pathwise Prep does not publish confidential assessment content. Report a concern