MCPcopy Create free account
hub / github.com/Tiwarishashwat/InterviewCodes / countSubIslands

Method countSubIslands

CountSubIsIland.java:23–38  ·  view source on GitHub ↗
(int[][] grid1, int[][] grid2)

Source from the content-addressed store, hash-verified

21 return isIsland;
22 }
23 public int countSubIslands(int[][] grid1, int[][] grid2) {
24 rows = grid1.length;
25 cols = grid1[0].length;
26 boolean visited[][] = new boolean[rows][cols];
27 int count=0;
28 for(int i=0;i<rows;i++){
29 for(int j=0;j<cols;j++){
30 if(!visited[i][j] && grid2[i][j]==1){
31 if(dfs(i,j,grid1,grid2,visited)){
32 count++;
33 }
34 }
35 }
36 }
37 return count;
38 }
39}

Callers

nothing calls this directly

Calls 1

dfsMethod · 0.95

Tested by

no test coverage detected