Recipe Management System

Asked at AirbnbOnline assessment

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

  1. 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. Adding pasta fails, because names are unique ignoring case, and it does not use up an id, so Soup is recipe2. 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. After recipe1 is deleted, the name Pasta is free again and the new recipe gets recipe3, not recipe1.

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.