← Questions

Course schedule: finish every course and find an order

0
AmazonCodingLast asked Jul 2026

You have n courses and a list of prerequisite pairs.

  1. Decide whether every course can be completed. This fails exactly when the prerequisites contain a cycle.
  2. Return one valid order to take all the courses, or an empty result when there is none.

It is also asked as resolving package dependencies, where a cycle must be reported.

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding