MCPcopy Create free account
hub / github.com/codedecks-in/LeetCode-Solutions / dfs

Method dfs

C++/Course-Schedule.cpp:17–30  ·  view source on GitHub ↗

helper function

Source from the content-addressed store, hash-verified

15
16 // helper function
17 bool dfs(vector<vector<int>>& adjlist, vector<int>& visited, int i) {
18
19 // base condition
20 if(visited[i]==1) return false;
21 visited[i]=1; // mark as being visited
22
23 for(int a:adjlist[i]) {
24 if(!dfs(adjlist, visited, a)) // dfs(adjlist, visited, a) == false
25 return false;
26 }
27
28 visited[i] = 2; // mark as visited
29 return true;
30 }
31
32
33 bool canFinish(int numc, vector<vector<int>>& prereq) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected