Detect cycles in a prerequisite graph to see if all courses can be completed.
Constraints
Example
>>> can_finish(2, [[1, 0]]) True >>> can_finish(2, [[1, 0], [0, 1]]) False >>> can_finish(3, [[0, 1], [1, 2]]) True
Recent Submissions
No submissions yet — hit Run Tests to try!
Hints