Practice Find All Possible Recipes from Given Supplies
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Find All Possible Recipes from Given Supplies
Problem Statement
You have information about n different recipes. You are given a string array recipes and a 2D string array ingredients. The ith recipe has the name recipes[i], and you can create it if you have all the needed ingredients from ingredients[i]. A recipe can also be an ingredient for other recipes, i.e., ingredients[i] may contain a string that is in recipes. You are also given a string array supplies containing all the ingredients that you initially have, and you have an infinite supply of all of them. Return a list of all the recipes that you can create. You may return the answer in any order. Note that two recipes may contain each other in their ingredients.
Source: Find All Possible Recipes from Given Supplies on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
recipes = ["bread"], ingredients = [["yeast","flour"]], supplies = ["yeast","flour","corn"]
["bread"]
# Example 2
recipes = ["bread","sandwich"], ingredients = [["yeast","flour"],["bread","meat"]], supplies = ["yeast","flour","meat"]
["bread","sandwich"]
# Example 3
recipes = ["bread","sandwich","burger"], ingredients = [["yeast","flour"],["bread","meat"],["sandwich","meat","bread"]], supplies = ["yeast","flour","meat"]
["bread","sandwich","burger"]
Constraints
Related LeetCode Problems
Practice more problems similar to Find All Possible Recipes from Given Supplies.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.