Schedule the Courses — Solution & Editorial
Kahn's algorithm with a min-heap instead of a queue: always emit the smallest currently-available course.
Complexity: O((N + M) log N)
Kahn's algorithm with a min-heap instead of a queue: always emit the smallest currently-available course.
Complexity: O((N + M) log N)