Google·Software Engineer·Technical Phone Screen
- You have a set of recipes forming a dependency graph (e.g. a cake requires sugar, oil, flour, eggs; sugar itself is made from cane sugar), and a stock of raw ingredients with given quantities. For a requested item and quantity, determine whether it can be produced from what's in stock. You need to define your own data structures and design a recursive algorithm that breaks the goal down to raw ingredients and checks availability.
“Spent probably five minutes just staring at the problem trying to figure out if it was a tree or a proper DAG.”