30:00
You have n recipes. recipes[i] can be made once you have every item in ingredients[i], and an ingredient may itself be another recipe. supplies lists the items you start with in unlimited quantity. Return every recipe you can make, in any order.
n=recipes.length=ingredients.lengthn = \text{recipes.length} = \text{ingredients.length}n=recipes.length=ingredients.length
1≤n≤1001 \leq n \leq 1001≤n≤100
1≤ingredients[i].length,supplies.length≤1001 \leq \text{ingredients}[i].\text{length}, \text{supplies.length} \leq 1001≤ingredients[i].length,supplies.length≤100
1≤recipes[i].length,ingredients[i][j].length,supplies[k].length≤101 \leq \text{recipes}[i].\text{length}, \text{ingredients}[i][j].\text{length}, \text{supplies}[k].\text{length} \leq 101≤recipes[i].length,ingredients[i][j].length,supplies[k].length≤10
All values are lowercase English letters; recipes and supplies combined are unique; each ingredients[i] has no duplicates.
Run code to see results.
1 recipe and 3 starting supplies. A recipe is ready once every one of its ingredients is in hand.
pantry
grey = supply, green = made, dim = already used
yeast
flour
corn
queue
not filled yet
recipes
bread
?
made so far
[]
Each recipe needs a list of ingredients, some of which are other recipes. Starting from an unlimited stock of supplies, return every recipe that can eventually be made.