DEV Community

Discussion on: Topological sort, Solving Google Interview Question

Collapse
 
indefinitelee profile image
Lee Wilson

Small issue: graph[from].add(to); should be .push (to) instead.

but also i am not getting same output as you for that portion of the function, can you specify the parameters you are calling with?
my graph variable shows
[ [ 2, 1 ], [], [ 3, 4 ], [ 6 ], [ 5, 6 ], [], [] ]

Collapse
 
akhilpokle profile image
Akhil

Omg thanks for pointing out, the graph is of another problem I am working on and I miss-matched it.

Graph is :[[2,0],[2,1],[3,2],[4,2],[4,5],[6,3],[6,4]]

I have updated the code :).

Thanks again for pointing out my mistake.

Collapse
 
dalgleish profile image
Andrew

Thanks for publishing this, and maintaining it.

I think the e.g input in the article has a mistake:

[5,4], should be [4,5],

Thread Thread
 
akhilpokle profile image
Akhil

Thanks for reading the article :), and updated my mistake.

Thread Thread
 
_arun_j_ profile image
Arun J

Hi,
Above the second diagram, it is still not corrected

For eg : if give data is [[2,0],[2,1],[3,2],[4,2],[5,4],[6,3],[6,4]]

Collapse
 
petelomax profile image
petelomax

I cannot see where you corrected that but it is still wrong just above step 1.

Thread Thread
 
_arun_j_ profile image
Arun J

For eg : if give data is [2,0],[2,1],[3,2],[4,2],[5,4],[6,3...