Parcel Attribute Store
Asked at Airbnb
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
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:
setstoresred, then overwrites it withblue. The update that expectsredfails because the current value isblue, and the value staysblue. The update that expectsbluesucceeds, so the value isgreen. A name or parcel that was never set reads asnull.