Record Store

Asked at MetaPhone screen

Reported by the problem's creator, not verified

Build an in-memory record store as a class RecordStore. A record is addressed by a key and holds named fields, each holding a string value. Every test creates one RecordStore() and runs a sequence of calls, checking every return value; methods that return nothing are checked as None. A test only calls methods introduced so far.

Examples

  1. Example 1

    Input: init = [], operations = [["set",["u1","name","ann"]],["get",["u1","name"]],["get",["u1","age"]],["get",["u2","name"]],["set",["u1","name","bob"]],["get",["u1","name"]],["delete",["u1","age"]],["delete",["u1","name"]],["get",["u1","name"]]]

    Output: [null,"ann",null,null,null,"bob",false,true,null]

    Explanation: get of an unset field or an unknown key returns None. The second set replaces ann with bob. Deleting age returns False because it was never set; deleting name returns True, after which get returns None.

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.