Detect whether a directed graph contains a cycle.
Constraints
Example
>>> has_cycle(2, [[0,1]]) False >>> has_cycle(2, [[0,1],[1,0]]) True >>> has_cycle(3, [[0,1],[1,2],[2,0]]) True >>> has_cycle(1, [[0,0]]) True
Recent Submissions
No submissions yet — hit Run Tests to try!
Hints