Find All Possible Recipes from Given Supplies
Try to solve the Find All Possible Recipes from Given Supplies problem.
We'll cover the following
Statement
A list of recipes a chef can prepare from the supplied items is given. Ingredients required to prepare a recipe are mentioned in the ingredients
list. The recipe has the name , and you can create it if you have all the needed ingredients from the list. A recipe may be listed as an ingredient in a different recipe. For example, the input may specify that custard is an ingredient in a trifle recipe or that trifle is an ingredient in a custard recipe.
Identify which recipes a chef can prepare from the given ingredients from the supplies
list.
Note: It is also considered valid input for two recipes to list each other in their ingredients. For example, the input may specify that custard is an ingredient in a trifle recipe and also that trifle is an ingredient in a custard recipe. Of course, if those are the only two recipes provided in the input, the expected output is an empty list.
Constraints:
-
recipes.length
ingredients.length
-
n
-
ingredients[i].length
,supplies.length
-
recipes[i].length
,ingredients[i][j].length
,supplies[k].length
recipes[i]
,ingredients[i][j]
, andsupplies[k]
consist only of lowercase English letters.- All the combined values of
recipes
andsupplies
are unique. - Each
ingredients[i]
doesn’t contain any duplicate values.
Examples
Create a free account to view this lesson.
Continue your learning journey with a 14-day free trial.
By signing up, you agree to Educative's Terms of Service and Privacy Policy