Amazon interview question

Coding questions were asked regarding topological sorting