Course Schedule
Return true if it is possible to finish all courses given prerequisites.
Examples
Input: [2,[[1,0]]]
Output: true
Input: [2,[[1,0],[0,1]]]
Output: false
Hints
Represent the courses and prerequisites as a directed graph, where an edge from course A to course B indicates that B must be taken before A.
Perform a topological sort on the graph. If the sort includes all courses, return true; otherwise, return false.
Use Kahn's algorithm (BFS-based topological sort) to count the number of courses processed. If the count matches the total number of courses, return true; otherwise, return false.
Related Problems
Course Schedule
Return true if it is possible to finish all courses given prerequisites.