give direct acyclic graph DAG n node label 0 n 1 find possible path node 0 node n 1 return orderthe graph give follow graphi list node visit node ie direct edge node node graphij Example 1input graph 1233output 013023explanation there path 0 1 3 0 2 3example 2input graph 43132434output 04034013401234014 Constraintsn graphlength2 n 150 graphij ngraphij ie selfloopsAll element graphi uniquethe input graph guarantee DAG