Preparing your design workspace

Loading the problem and your saved attempt…

Design and Implement a Dependency-Aware Package Manager

Install dependency graphs, reject unsafe removals, and clean orphaned automatic dependencies while retaining explicit installs.

For this exercise, assume the following practice scope. Design and implement an in-memory package manager. A fixed package catalog gives each package ID a dependency list. install(packageId) explicitly installs the requested package and recursively installs every transitive dependency before its dependent.

An already installed automatic dependency becomes explicitly retained when the user installs it directly. A catalog cycle, missing dependency, or validation failure rejects the whole operation without a partial install. uninstall(packageId) rejects removal when another installed package still depends on it.

Otherwise it removes the explicit request and recursively removes dependencies that are no longer required by any installed package and were never explicitly installed.

For example, if A depends on B and C and C depends on D, installing A installs all four; installing B explicitly and then uninstalling A removes A, C, and D while retaining B. Return deterministic install or removal order and named errors. Implement install and uninstall and state complexity.

Remote repositories, semantic-version solving, scripts, downloads, persistence, and concurrent processes are outside scope.