my code link click
i cannot find the mistake plese help
my logic:
given case is
6
2 -1 1 5 -1 4
-
i consider graph with edges like 3->1, 1->2, then 6->4 and 4->5
-
now i do a dfs from vertex with indegree 0 gradually e.g. from 3 here first and then from 6
-
but as soon as i get a vertex with -1 i stop
-
so, they get marked
3 gets 1 1 gets 2
6 gets 3 4 gets 4 -
then after this i number vertices with -1 in decreasing order i.e.
5 gets 5 2 gets 6