Algorithm · Amazon · Medium
You are given a dependency graph of software packages and the name of a package, target, that needs to be installed. Every package exposes an install() method, but that method sets up just that one package; it never pulls in any of the package's dependencies on its own. Your job is to drive the installation so that no package is installed until everything it depends on is already in place. Implement: In graph, the entry for a package p lists the packages that p depends on…