Given a schedule of courses with their prerequisites, return the order in which they can be finished. If a valid order exists, you must return the correct order; otherwise, return an empty array.
Each course is represented as
(course, prerequisites)(course, prerequisites[i])courseprerequisites[i]This problem is a variation of the Topological Sort problem. However, in this case, if there's a cycle in the graph, we should return an empty array, as a valid order may not exist.
1 <= course1.length == course2.length <= 200 <= prerequisite <= course.length - 1courseprerequisitesInput: {"input_data":[1,2,3]} Output: [1,2,3]
Solve problems, verify your skills, and earn XP.