MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / dfsUtil

Method dfsUtil

GeeksForGeeks/Number of islands/Islands.java:20–35  ·  view source on GitHub ↗
(ArrayList<ArrayList<Integer>> A, int i, int j)

Source from the content-addressed store, hash-verified

18 }
19
20 static void dfsUtil(ArrayList<ArrayList<Integer>> A, int i, int j){
21 if(i<0 || i>=A.size() || j<0 || j>=A.get(i).size() || A.get(i).get(j)==0) // these are the base condiation
22 return ;
23 //we will try to cover all direction
24 //we use the base condition in any DFS opertion i or j valuw will be negative so it is not possible so we will
25 //-return nothing
26 A.get(i).set(j,0);
27 dfsUtil(A,i+1,j);
28 dfsUtil(A,i-1,j);
29 dfsUtil(A,i,j+1);
30 dfsUtil(A,i,j-1);
31 dfsUtil(A,i+1,j-1);
32 dfsUtil(A,i+1,j+1);
33 dfsUtil(A,i-1,j-1);
34 dfsUtil(A,i-1,j+1);
35 }
36}

Callers 1

findIslandsMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected