Given a list of recipes, their ingredient lists, and your initial supplies, return all recipes you can make. Pattern focus: Applications. This is a classic dependency-resolution problem solved with a topological queue.
recipes = recipe names, ingredients = required ingredients per recipe, supplies = initial available items
all recipes that can be made
Example 1:
Input:
recipes = ["bread","sandwich"] ingredients = [["yeast","flour"],["bread","meat"]] supplies = ["yeast","flour","meat"]
Output:
["bread","sandwich"]
Explanation:
Bread can be made first, which unlocks sandwich.
Example 2:
Input:
recipes = ["burger","fries"] ingredients = [["bread","meat"],["potato"]] supplies = ["meat","potato"]
Output:
["fries"]
Explanation:
Only fries can be prepared from the available supplies.
Example 3:
Input:
recipes = ["cake"] ingredients = [["flour","egg"]] supplies = ["flour","egg"]
Output:
["cake"]
Explanation:
All ingredients are available, so the recipe can be prepared.