Course schedule: finish every course and find an order

0
Remix

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.

AmazonTechnical phone screenLast asked Jul 2026
No answer yet. Write the first one; the best answer gets endorsed.