In-Memory Object Manager
Asked at Airbnb
Reported by the problem's creator, not verified
You are building an in-memory object manager as the class ObjectManager. Each object, identified by a string id, holds named fields, each with a string value.
Examples
Example 1
Input: init =
[], operations =[["set",["user1","name","alice"]],["set",["user1","nick","ali"]],["get",["user1","name"]],["get",["user1","age"]],["get",["user2","name"]],["set",["user1","name","bob"]],["get",["user1","name"]],["delete_value",["user1","nick"]],["delete_value",["user1","nick"]],["get",["user1","nick"]],["delete_object",["user2"]],["delete_object",["user1"]],["get",["user1","name"]],["delete_object",["user1"]]]Output:
[null,null,"alice",null,null,null,"bob",true,false,null,false,true,null,false]Explanation:
setstores two fields onuser1, and the secondsetofnamereplacesalicewithbob.getof a field or an object that was never set isnull.delete_valuereturnstruethe first time it removesnickandfalsethe second time.delete_objectreturnsfalseforuser2, which has no fields, andtrueforuser1, after which every field of it is gone and a second delete returnsfalse.