In-Memory Key-Value Store
Asked at Snowflake· Screen
Reported by the problem's creator, not verified
Implement an in-memory key-value store as a class TxStore. Keys are lowercase strings and values are integers. Each test creates one TxStore and calls its methods in order; the result records every call's return value, including None. You build the store in stages: each part adds behavior on top of the previous parts, and all earlier behavior must keep working.
Examples
Example 1
Input: init =
[], operations =[["put",["a",5]],["get",["a"]],["get",["b"]],["delete",["a"]],["get",["a"]],["delete",["a"]]]Output:
[null,5,null,true,null,false]Explanation: put(a,5) stores 5; get(a) returns 5; get(b) finds nothing; delete(a) removes the key and returns True; get(a) is then None, and the second delete(a) finds nothing and returns False.