Given numCourses and prerequisites, return an ordering of courses to finish all of them. If impossible, return an empty array.
With numCourses = 4 and prerequisites = [[1,0],[2,0],[3,1],[3,2]]:
- Course 0 has no prereqs. Take it first.
- Courses 1 and 2 need 0. Take them next (either order).
- Course 3 needs 1 and 2. Take it last.
- Valid ordering:
[0, 1, 2, 3]or[0, 2, 1, 3].
With numCourses = 2 and prerequisites = [[1,0],[0,1]]:
- Circular dependency. Return
[].
Constraints: .