Course Schedule II
Medium · Graphs · about 20 minutes
Asked at Amazon, Meta, Google, DoorDash, Netflix, Snowflake, Uber, Apple, Datadog, Elastic, Rubrik, Grab, Swiggy.
There are numCourses courses labelled 0..numCourses-1. prerequisites[i] = [a, b] means you must take course b before course a. Return an order in which you can take all the courses, or an empty list if it's impossible (the prerequisites contain a cycle). Any valid order is accepted.