DFS intuitive solution
IntuitionThink of this problem in terms of connected Components. We can catch all the fish in One connected component of the matrix. If we run a dfs on a cell w
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
Think of this problem in terms of connected Components. We can catch all the fish in One connected component of the matrix. If we run a dfs on a cell which is not visited, it will give us the count of all the fishes in that component. We can maintain a visited matrix and whenever we find a cell which is not land and has not been visited before, that means it is a new component of the graph and we run dfs on that cell. We take the answer as max of current answer so far and the fishCount returned by current call.

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
int dx[] = {0, -1, 0, 1};
int dy[] = {-1, 0, 1, 0};
class Solution {
public:
    int n, m;
    int dfs(int x, int y, vector<vector<bool>>& vis,
            vector<vector<int>>& grid) {
        vis[x][y] = true;
        int cnt = grid[x][y];

        for (int i = 0; i < 4; i++) {
            int nrow = x + dx[i], ncol = y + dy[i];
            if (nrow >= 0 && nrow < n && ncol >= 0 && ncol < m &&
                !vis[nrow][ncol] && grid[nrow][ncol] > 0) {
                cnt += dfs(nrow, ncol, vis, grid);
            }
        }
        return cnt;
    }
    int findMaxFish(vector<vector<int>>& grid) {

        n = grid.size(), m = grid[0].size();
        int ans = 0;
        vector<vector<bool>> vis(n, vector<bool>(m, 0));
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (grid[i][j] > 0 && !vis[i][j])
                    ans = max(ans, dfs(i, j, vis, grid));
            }
        }
        return ans;
    }
};
```
['C++']