...
/Find All Possible Recipes from Given Supplies
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
You are given information about recipes
, and its corresponding ingredients are provided in the 2D array ingredients
. The recipes[i]
, can be prepared if all the necessary ingredients listed in ingredients[i]
are available. Some ingredients might need to be created from other recipes, meaning ingredients[i]
may contain strings that are also in recipes
.
Additionally, you have a string array supplies
that contains all the ingredients you initially have, and you have an infinite supply of each.
Return a list of all the recipes you can create. The answer can be returned in any order.
Note: It is possible for two recipes to list each other as ingredients. However, if these are the only two recipes provided, the expected output is an empty list.
Constraints:
n
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.
By signing up, you agree to Educative's Terms of Service and Privacy Policy