Course Schedule (DAG Validity)
Problem
Given a number of courses and a list of prerequisite pairs [a, b] meaning "b must be taken before a", return whether it is possible to finish all courses (i.e. the prerequisite graph has no cycle).
Example
n=2, [[1,0]] -> true
n=2, [[1,0],[0,1]] -> false
Constraints
- 1 ≤ n ≤ 2000
added …