3
vector<string> findAllRecipes(vector<string> &recipes, vector<vector<string>> &ingredients,4
vector<string> &supplies) {5
unordered_map<string, int> indegree;6
for (auto i : recipes) indegree[i] = 0; // Initially indegree of every recipe is 08
unordered_map<string, vector<string>> graph;10
for (int i = 0; i < recipes.size(); i++) {11
for (int j = 0; j < ingredients[i].size(); j++) {12
if (find(supplies.begin(), supplies.end(), ingredients[i][j]) ==13
supplies.end()) { // finds if the ingredient exist in the supply or not15
graph[ingredients[i][j]].push_back(recipes[i]); // If not then ingredients[i][j] is16
// required to prepare the recipes[i] i.e17
// bread--->burger, sandwitch ---> burger19
indegree[recipes[i]]++; // increase the indegree of the recipe , for20
// example , bread->burger,sandwitch-->burger21
// , now indegree of burger is 225
queue<string> q; // Now simple topo sort using bfs (Kahn's algorithm)26
for (auto i : indegree) {27
if (i.second == 0) q.push(i.first);32
string front = q.front();35
for (auto i : graph[front]) {37
if (!indegree[i]) q.push(i);