[C++, Java] Explained - DFS with node sum || Very simple & easy to understand solution
Up vote if you like the solution ApproachTrick is to keep traversing the grid from (0,0) with dfs & adding the values of each dfs traverse.
Keep adding all non
<b> Up vote if you like the solution </b>

# Approach
Trick is to keep traversing the grid from (0,0) with dfs & adding the values of each dfs traverse.
Keep adding all non-zero value traversed is the total no of fish possible on that connected cells.
So keep taking the maximum of each dfs run and return it as the answer.

Note : Set the node value to 0 once we traversed a node, to avoid retraversing the same node again.

# Code 

```cpp []
int dir[4][2] = {{1,0}, {0,1}, {-1, 0}, {0,-1}};

int dfs(vector<vector<int>>& grid, int r, int c){
    if(r < 0 || c < 0 || r >= grid.size() || c >= grid[0].size() || grid[r][c] == 0) return 0;
    int res = grid[r][c];
    grid[r][c] = 0;
    for(auto d: dir)  res += dfs(grid, r+d[0], c+d[1]);
    return res;
}

int findMaxFish(vector<vector<int>>& grid) {
    int ans = 0;
    for(int i = 0; i< grid.size(); ++i){
        for(int j =0; j < grid[0].size(); ++j) ans = max(ans, dfs(grid, i, j));
    }
    return ans;
}
```

```java []
int[][] dir = new int[][]{{1,0}, {0,1}, {-1,0}, {0,-1}};

int dfs(int[][] grid, int r, int c){
    if(r < 0 || c < 0 || r >= grid.length || c >= grid[0].length || grid[r][c] == 0) return 0;
    int res = grid[r][c];
    grid[r][c] = 0;
    for(int[] d: dir) res += dfs(grid, r+d[0], c+d[1]);
    return res;
}

int findMaxFish(int[][] grid) {
    int ans = 0;
    for(int i = 0; i < grid.length; ++i){
        for(int j = 0; j < grid[0].length; ++j) ans = Math.max(ans, dfs(grid, i, j));
    }
    return ans;
}
```

<b>Here is an article of my last interview experience - A Journey to FAANG Company, I recomand you to go through this to know which all resources I have used & how I cracked interview at Amazon:
https://leetcode.com/discuss/interview-experience/3171859/Journey-to-a-FAANG-Company-Amazon-or-SDE2-(L5)-or-Bangalore-or-Oct-2022-Accepted
['C++', 'Java']