Parcel Attribute Store

Asked at AirbnbOnline assessment

Reported by the problem's creator, not verified

You are building an in-memory store of parcel attributes as the class ParcelStore. Every method takes the call's timestamp as its first argument.

Examples

  1. Example 1

    Input: init = [], operations = [["set",[1,"p1","color","red"]],["get",[2,"p1","color"]],["get",[3,"p1","size"]],["get",[3,"p2","color"]],["set",[4,"p1","color","blue"]],["update_if_match",[5,"p1","color","red","green"]],["get",[6,"p1","color"]],["update_if_match",[7,"p1","color","blue","green"]],["get",[8,"p1","color"]]]

    Output: [null,"red",null,null,null,false,"blue",true,"green"]

    Explanation: set stores red, then overwrites it with blue. The update that expects red fails because the current value is blue, and the value stays blue. The update that expects blue succeeds, so the value is green. A name or parcel that was never set reads as 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.