MCPcopy Index your code
hub / github.com/neetcode-gh/leetcode / isCyclic

Method isCyclic

java/0207-course-schedule.java:24–39  ·  view source on GitHub ↗
(List<List<Integer>> adj, int[] visited, int curr)

Source from the content-addressed store, hash-verified

22 }
23
24 private boolean isCyclic(List<List<Integer>> adj, int[] visited, int curr) {
25 if (visited[curr] == 2) {
26 return true;
27 }
28
29 visited[curr] = 2;
30 for (int i = 0; i < adj.get(curr).size(); i++) {
31 if (visited[adj.get(curr).get(i)] != 1) {
32 if (isCyclic(adj, visited, adj.get(curr).get(i))) {
33 return true;
34 }
35 }
36 }
37 visited[curr] = 1;
38 return false;
39 }
40}

Callers 1

canFinishMethod · 0.95

Calls 2

sizeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected