Key-Value Store

Asked at Databricks· Onsite

Reported by the problem's creator, not verified

Import another question

Design a string-to-string store that also tracks how often each key is read. Each test drives a single KVStore instance through a sequence of method calls and checks every return value.

Examples

  1. Example 1

    Input: init = [], operations = [["get",["a"]],["put",["a","x"]],["get",["a"]],["put",["a","y"]],["get",["a"]],["put",["b",""]],["get",["b"]],["get",["c"]]]

    Output: ["NULL","OK","x","OK","y","OK","","NULL"]

    Explanation: A get on a missing key returns NULL. After put(a, x) the next get returns x, and overwriting a with y makes the following get return y. An empty string is a real value, so get(b) returns it rather than NULL.

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.