There are numCourses courses (0 to numCourses-1). prerequisites[i] = [ai, bi] means you must take bi before ai. Return the ordering of courses to finish all. If impossible, return an empty array.
Input: numCourses = 2, prerequisites = [[1,0]]
Output: [0,1]
Topics: graphs
Asked by: Amazon, Google, Meta, Microsoft, Apple, Bloomberg
Time complexity: O(V+E). Space complexity: O(V+E).