Amazon interview question

Topological Sort of Graph Question