Find All Possible Recipes from Given Supplies
You have n recipes: recipes[i] can be made only if you have every item in ingredients[i]. An ingredient may itself be another recipe. You also have an array supplies of items you own in unlimited quantity. Return all recipes you can create, in any order.
Open official problem prompt ↗Determine which recipes are actually buildable given a starting pantry, accounting for recipes that serve as ingredients to other recipes.
Like a crafting tech tree in a game: you start with raw resources, craft an intermediate item, and that intermediate unlocks the next tier. You keep crafting whatever has all its inputs satisfied until nothing new can be made.
- Input
- recipes = ["bread","sandwich"], ingredients = [["yeast","flour"],["bread","meat"]], supplies = ["yeast","flour","meat"]
- Output
- ["bread","sandwich"]
- Why
- Bread is made from the supplies yeast and flour; once bread exists it plus the supply meat makes sandwich.
n == recipes.length == ingredients.length1 <= n <= 1001 <= ingredients[i].length, supplies.length <= 1001 <= recipes[i].length, ingredients[i][j].length, supplies[k].length <= 10recipes[i], ingredients[i][j], and supplies[k] consist only of lowercase English lettersAll the values of recipes and supplies combined are uniqueEach ingredients[i] does not contain any duplicate values