GitLab's monorepo CI/CD system failed to build after a developer accidentally created a circular dependency between packages. The build runner hung indefinitely waiting for Package A (which waits for B, which waits for A). Before executing any build, the system must compute a valid topological order and fail fast if a cycle exists.
Our monorepo build system fails because packages depend on each other. Given packages and dependency pairs (A depends on B), return a valid build order. Raise an error if circular dependency exists.
βΆ Run Code to test against examples Β· Submit to judge all 5 test cases