Save 25%Black Friday: 25% off all plans — use code BLACKFRIDAY2026 at checkout. Ends Friday, Dec 4.Claim the deal

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