Leetcode 2115: Find All Possible Recipes from Given Supplies
4 min readJan 13, 2022
--
In this problem, we are trying to figure the list of recipes that we can make out of a list of ingredients in unlimited quantity. The difficulty comes from the fact that in the list of ingredients necessary for each recipe, there can be another recipe itself.
You have information about
n
different recipes. You are given a string arrayrecipes
and a 2D string arrayingredients
. Theith
recipe has the namerecipes[i]
, and you can create it if you have all the needed ingredients fromingredients[i]
. Ingredients to a recipe may…