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

Method findMaxFish

maximumNumberOfFishesInAGrid.java:4–17  ·  view source on GitHub ↗
(int[][] grid)

Source from the content-addressed store, hash-verified

2 int rows;
3 int cols;
4 public int findMaxFish(int[][] grid) {
5 rows = grid.length;
6 cols = grid[0].length;
7 int maxFishes=0;
8 //find max of all components
9 for(int i=0;i<rows;i++){
10 for(int j=0;j<cols;j++){
11 if(grid[i][j]!=0){
12 maxFishes=Math.max(maxFishes, dfs(i,j,grid));
13 }
14 }
15 }
16 return maxFishes;
17 }
18 public int dfs(int r, int c, int grid[][]){
19 //base case
20 //out of the matrix

Callers

nothing calls this directly

Calls 1

dfsMethod · 0.95

Tested by

no test coverage detected