Recipe Management System
Asked at Airbnb
Reported by the problem's creator, not verified
You are building a recipe manager as the class RecipeManagementSystem. Recipe ids are strings recipe1, recipe2, and so on, assigned in order of creation.
Examples
Example 1
Input: init =
[], operations =[["add_recipe",["Pasta",["Tomato","Salt"],["Boil","Serve"]]],["get_recipe",["recipe1"]],["add_recipe",["pasta",["Egg"],["Fry"]]],["add_recipe",["Soup",["Water"],["Heat"]]],["get_recipe",["recipe9"]],["update_recipe",["recipe1","PASTA",["Tomato"],["Boil"]]],["get_recipe",["recipe1"]],["update_recipe",["recipe1","soup",["Tomato"],["Boil"]]],["update_recipe",["recipe5","Other",["Tomato"],["Boil"]]],["delete_recipe",["recipe1"]],["delete_recipe",["recipe1"]],["get_recipe",["recipe1"]],["add_recipe",["Pasta",["Rice"],["Cook"]]],["get_recipe",["recipe3"]]]Output:
["recipe1",["Pasta","Tomato,Salt","Boil,Serve"],null,"recipe2",[],true,["PASTA","Tomato","Boil"],false,false,true,false,[],"recipe3",["Pasta","Rice","Cook"]]Explanation: The first recipe gets
recipe1. Addingpastafails, because names are unique ignoring case, and it does not use up an id, soSoupisrecipe2. An unknown id reads as[]. A recipe may be updated to a different casing of its own name, but not to another recipe's name. Afterrecipe1is deleted, the namePastais free again and the new recipe getsrecipe3, notrecipe1.