Amazon interview question

Topological Sort, Course Scheduling Question