Amazon interview question

Course schedule problem using topological sort