Easy to understand C++ Solution
IntuitionThis problem is similar to: https://leetcode.com/problems/number-of-islands/description/Start a DFS from every water node to find how many fishes can b
# Intuition
This problem is similar to: https://leetcode.com/problems/number-of-islands/description/

Start a DFS from every water node to find how many fishes can be caught starting from current node.

Once fishes from current index(i, j) are caught - it can be marked visited to avoid recomputation.

Note that one water node can be part of at max one water body. Hence, if we start a dfs from current node, we will explore all the water nodes adjacent to it such that it form a water body surrounded by land in all direction or visit the entire grid.

# Approach
DFS to find the largest number of fishes in one water body.

maximum number of fishes caught from any of the water body will be our answer.

# Complexity
- Time complexity:
O(n)

- Space complexity:
O(1)

# Code
```cpp []
class Solution {
public:
    vector<pair<int, int>> direction = {{1, 0}, {-1, 0}, {0, -1}, {0, 1}};
    int n, m;
    int dfs(vector<vector<int>> & grid, int i, int j) {
        if (i < 0 || i == n || j < 0 || j == m) return 0;
        if (grid[i][j] == 0) return 0;
        int ans = grid[i][j];
        grid[i][j] = 0;
        for (auto dir: direction) {
            ans += dfs(grid, i + dir.first, j + dir.second);
        }
        return ans;
    }
    int findMaxFish(vector<vector<int>>& grid) {
        n = grid.size(), m = grid[0].size();
        int maxfish = 0;
        for (int i = 0; i < n; i ++) {
            for (int j = 0; j < m; j ++) {
                if (grid[i][j] != 0) {
                    int fish = dfs(grid, i, j);
                    maxfish = max(fish, maxfish);
                }
            }
        }
        return maxfish; 
    }
};
```
['Depth-First Search', 'Matrix', 'C++']