Given
numCourses courses and a prerequisites array prerequisites, where [a, b] means: to take a, you must first complete b. Return an order to finish all courses, or an empty array if there is a cycle.Example 1
Input: numCourses = 2, prerequisites = [[1,0]]
Output: [0,1]
Explanation: Course 0 first, then 1.
Output: [0,1]
Explanation: Course 0 first, then 1.
Example 2
Input: numCourses = 3, prerequisites = [[1,0],[1,2],[0,1]]
Output: []
Explanation: Cycle in dependencies.
Output: []
Explanation: Cycle in dependencies.