← Google Interview Insights

Google·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Jun 2026

Summary

Google SWE coding round, one question on recipe dependencies. Pretty clean problem once you see the graph structure, but I fumbled around for a bit before getting there.

Questions Asked (1)

Q1

Given n recipes, each with a list of required ingredients and an output, plus a list of initially available supplies, return all recipes you can actually make. A recipe can be made if every ingredient is either in your supplies or is itself a makeable recipe.

Algorithms & Data Structures
Author's notes

Took me longer than it should have to see this as a graph problem.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the problem as a dependency graph where recipes depend on ingredients and other recipes. Use a topological sort or BFS/DFS to iteratively determine which recipes can be made, starting from the initially available supplies. Return all recipes that become makeable.

Pro tip: Clarify edge cases upfront, such as cycles in recipe dependencies or duplicate ingredients, and discuss how your approach handles them. This shows thoroughness and prevents incorrect assumptions.

1. Understand the problem and clarify constraints

Ask about input format, whether recipes can depend on each other cyclically, and if ingredients are case-sensitive. Confirm that you need to return all makeable recipes, not just a boolean.

2. Model as a graph and choose an algorithm

Represent recipes and ingredients as nodes, with directed edges from ingredients to recipes. Use topological sort (Kahn's algorithm) or BFS to process recipes whose dependencies are satisfied.

3. Implement the solution

Maintain a set of available items (initial supplies plus newly made recipes). Use a queue to process recipes whose ingredient counts drop to zero, and add their outputs to the available set.

4. Handle edge cases and validate

Check for cycles (unmakeable recipes), recipes with no ingredients, and duplicate ingredients. Test with small examples to ensure correctness.

5. Analyze complexity and discuss optimizations

Time complexity is O(N + E) where N is number of recipes/ingredients and E is total dependencies. Space is O(N + E). Mention potential optimizations like early termination or memoization if needed.

Key Points to Mention

  • Graph representation: recipes and ingredients as nodes, dependencies as edges.
  • Topological sorting or BFS with indegree counting to resolve dependencies.
  • Use of a set for O(1) lookups of available ingredients.
  • Handling cycles: recipes in a cycle cannot be made unless all ingredients are initially available.
  • Time and space complexity analysis.
  • Edge cases: empty supplies, recipes with no ingredients, duplicate ingredients.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.