NewProject Coding is here — build features and fix bugs in real codebases with an AI assistantSee what's new

Design an in-memory key-value store that supports nested transactions. The store should allow basic operations like setting a key-value pair, retrieving a value by key, removing a key, and counting how many records share a particular value. On top of these, you must provide transactional operations to start a transaction (begin), roll back recent changes (rollback), and apply them permanently (commit).

Implement the InMemoryKVDB class:

Test Cases
Input
Output
Expected