In-Memory Key-Value Store

Asked at Snowflake· Screen

Reported by the problem's creator, not verified

Import another question

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

  1. 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.

Import your own questions
Paste a question you were asked and get a full problem: statement, tests and a checked solution.
Import a question

Code

Loading editor…

Ln 1, Col 1

Start an attempt to use Coach.