← All problems
Course Schedule
MediumTopological Sort
Given numCourses and prerequisites where [a, b] means b must be taken before a, return true if all courses can be finished (no cycle).
Examples
Input: n=2, prereqs=[[1,0]]
Output: true
Input: n=2, prereqs=[[1,0],[0,1]]
Output: false
Hints
Solution
Language:
Loading editor…
Output0 lines
Run your code to see output here.
Click Run all tests to check your solution against 4 test cases.