01 · Question
Return the ordering of courses you should take to finish all courses. If impossible, return an empty array.
02 · Analysis
For [course, prerequisite], add prerequisite -> course. Queue every zero-indegree course, remove it, and decrement all dependent indegrees. The queue contains exactly the courses whose prerequisites are finished. A result shorter than numCourses proves a cycle somewhere in the graph. Time O(V+E), auxiliary space O(V), plus O(V+E) graph storage. Any valid order is acceptable.