- topological sort
- dfs
Use suppliesMap
to keep track all supplies and possible recipes.
By the default, all supplies are marked as POSSIBLE
One reciple can be treat as POSSIBLE
if and only if all its ingredients is POSSIBLE
Loop through the list of recipes.
- For each iteration,
dfs
all ingredients of the recipe. If all its ingredients isPOSSIBLE
, add it to theanswer
list.