Problem. There are n courses labelled 0 to n − 1, and a list of pairs [a, b] meaning "to take a you must first take
b". Return whether it's possible to finish all courses.
n = 2, prerequisites = [[1, 0]] → True (take 0, then 1)
n = 2, prerequisites = [[1, 0], [0, 1]] → False (each requires the other)
Draw an edge b → a for every pair ("b comes before a"). All courses can be finished exactly when this directed graph has no cycle: a cycle is a set of courses that each wait for another in the set, so none can ever start.
ML context. Every pipeline orchestrator (Airflow, Kubeflow, Dagster, a build system, a feature store's derived features) must check that its task graph is a DAG before running it, and report the cycle if it isn't. Autograd graphs are DAGs by construction; a model config that wires a layer's output into an earlier layer creates a cycle that a static graph compiler must reject (Changes A and B).