Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Find All Possible Recipes from Given Supplies
Bookmark
Brute Force
Topological Sort
DFS + Memoization
Input
Example 1
Chain
Partial
Custom
recipes
=
[bread, sandwich]
,
ingredients
=
[["yeast","flour"],["bread","meat"]]
,
supplies
=
[yeast, flour, meat]
yeast
flour
meat
bread
sandwich
Made:
no
bread
no
sandwich
Result:
Legend:
Supply
Recipe
Processing
Done
yeast
flour
meat
bread
sandwich
Made:
no
bread
no
sandwich
Result:
Legend:
Supply
Recipe
Processing
Done
yeast
flour
meat
bread
sandwich
Made:
no
bread
no
sandwich
Result:
Legend:
Supply
Recipe
Processing
Done
yeast
flour
meat
bread
sandwich
Made:
no
bread
no
sandwich
Result:
Legend:
Supply
Recipe
Processing
Done
yeast
flour
meat
bread
sandwich
Made:
yes
bread
no
sandwich
Result:
bread
bread
Legend:
Supply
Recipe
Processing
Done
yeast
flour
meat
bread
sandwich
Made:
yes
bread
no
sandwich
Result:
bread
bread
Legend:
Supply
Recipe
Processing
Done
yeast
flour
meat
bread
sandwich
Made:
yes
bread
yes
sandwich
Result:
bread
bread
sandwich
sandwich
Legend:
Supply
Recipe
Processing
Done
yeast
flour
meat
bread
sandwich
Made:
yes
bread
yes
sandwich
Result:
bread
bread
sandwich
sandwich
Legend:
Supply
Recipe
Processing
Done
yeast
flour
meat
bread
sandwich
Made:
yes
bread
yes
sandwich
Result:
bread
bread
sandwich
sandwich
Legend:
Supply
Recipe
Processing
Done
yeast
flour
meat
bread
sandwich
Made:
yes
bread
yes
sandwich
Result:
bread
bread
sandwich
sandwich
Legend:
Supply
Recipe
Processing
Done
yeast
flour
meat
bread
sandwich
Made:
yes
bread
yes
sandwich
Result:
bread
bread
sandwich
sandwich
Legend:
Supply
Recipe
Processing
Done
algo
master
.
io
Step:
Start with the 3 supplies available and no recipe made yet
0 / 9
Input
Example 1
Chain
Partial
Custom
recipes
=
[bread, sandwich]
,
ingredients
=
[["yeast","flour"],["bread","meat"]]
,
supplies
=
[yeast, flour, meat]
0 / 9
algo
master
.
io
Step:
Start with the 3 supplies available and no recipe made yet