Implement a KV store supporting set, get, delete, begin, rollback, and commit. Transactions nest: rollback undoes only the innermost; commit applies all open transactions. Rollback/commit with no open transaction returns False.
02Key insight
Maintain a stack of write-sets layered over the base map; reads check from innermost layer outward. A tombstone sentinel records deletes. Rollback pops a layer; commit flattens all layers into base.
Reads are O(depth) and some variants need COUNT(value). Alternative: undo-log per layer (apply writes to base, store prior values) gives O(1) reads and makes value-count indexes easy to maintain.