Algorithm · Amazon · Medium
Consider a system of tasks with dependencies between them. A pair [a, b] says that task a relies on task b. Whenever b is modified, a has to be executed again. You are given the number of tasks n, the list of dependency pairs prerequisites, and the list changed of tasks that were modified directly. Your job has three parts: Determine the full set of tasks that need to run again. This set includes every task in changed, plus every task that depends on one of them, either…