In the Find the Minimum Amount of Time to Brew Potions coding problem, you are given a set of recipes, each requiring several ingredients and a specific time to process. Some ingredients are raw, while others are intermediate potions that must be brewed first. This is a dependency-based timing problem where you want to find the total time required to brew a target potion, assuming you can brew multiple things in parallel.
Companies like Goldman Sachs and Google use this to test your understanding of Graph interview patterns, specifically Directed Acyclic Graphs (DAGs) and Longest Path logic. It evaluations your ability to model dependencies and calculate completion times in a system with concurrency. It’s similar to how build systems (like Make or Bazel) calculate compilation times.
This problem is solved using Topological Sort or DFS with Memoization.
node.processTime + max(Time to Complete all dependencies).Potion A: needs B and C, takes 5 mins. Potion B: needs D, takes 10 mins. Potion C: takes 2 mins. Raw D: takes 0 mins.
When you see a problem with "dependencies" and "parallel execution," think about the longest path in a DAG. The total time is the duration of the "Critical Path." Practice using Topological Sort to process nodes in the order they become available.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Make Array Elements Equal to Zero | Easy | Solve | |
| Ant on the Boundary | Easy | Solve | |
| Find the Student that Will Replace the Chalk | Medium | Solve | |
| Corporate Flight Bookings | Medium | Solve | |
| Number of Ways to Split Array | Medium | Solve |