DEV Community

Discussion on: Topological sort, Solving Google Interview Question

Collapse
ndaidong profile image
Dong Nguyen • Edited on

Thank you for your article. You explained as well, however your implementation may have some problems. I didn't run your code but I guess that it will not be able to work as expected. For example:

  • line 20 and line 37, the keyword int
for(int i=0;i<indegree.length;i++){
  • line 35, visited is Set, not Array, so you have to use add(), not push()
visited.push(node);

Please check and fix them :)

Collapse
akhilpokle profile image
Akhil Author

Omg, thanks for pointing out! Code updated :)