Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Find All Possible Recipes from Given Supplies

XPChallenge Points: 20
levelLevel: Medium

You are given a list of recipe names and the list of ingredients needed to prepare each recipe.
Some ingredients are already available to you in unlimited quantity.
A recipe can act as an ingredient for another recipe once it has been prepared.

Return all the recipes that can be successfully prepared using your initial supplies and any recipes you manage to make along the way.
You may return the result in any order.

Example 1:

Input: recipes = ["cake"] ingredients = [["flour","sugar","milk"]] supplies = ["sugar","flour","milk","butter"]

Output: ["cake"]

Example 2:

Input: recipes = ["juice","fruit_salad"] ingredients = [["apple","water"],["juice","banana"]] supplies = ["water","apple","banana"]

Output: ["juice","fruit_salad"]

Example 3:

Input: recipes = ["noodles","soup","ramen"] ingredients = [["flour","water"],["water","salt"],["noodles","soup"]] supplies = ["water","flour","salt"]

Output: ["noodles","soup","ramen"]

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result