Your question is Longest Path in a DAG. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
RAMP Consulting Group models dependency pipelines as a directed acyclic graph, where an edge u -> v means pipeline step u must complete before step v. Given the number of steps and dependency edges, return one longest pipeline as an ordered list of node IDs.
The path length is measured by the number of nodes. If multiple longest paths exist, return the lexicographically smallest path, meaning the path with the smallest differing node ID. Isolated nodes are valid paths of length one. The input is guaranteed to represent a DAG.
Implement longest_pipeline_path(n, edges).
n is an integer representing nodes 0 through n - 1.edges is a list of two-element lists [u, v], representing a directed edge from u to v.[] when n == 0.def longest_pipeline_path(n, edges):