Simple Java solution (2 methods)
Method 1Visisted and non Visited array conceptComplexity

Time complexity: O(m∗n)


Space complexity: O(m∗n)

CodeMethod 2Adding values of a matrix conceptCompl
# Method 1
# Visisted and non Visited array concept

# Complexity
- Time complexity: $$O(m*n)$$

- Space complexity: $$O(m*n)$$

# Code
```java []
class Solution {
    public int findMaxFish(int[][] grid) {


        int m = grid.length, n = grid[0].length;

        int maxi = 0;

        for(int i = 0; i < m; i++)
        {
            for(int j = 0; j < n; j++)
            {

                if(grid[i][j] != 0)
                {


                    boolean vis[][] = new boolean[m][n];

                    int a[] = new int[1];


                    dfs(grid, i, j, m, n, a, vis);

                    maxi = Math.max(maxi, a[0]);
                }
            }
        }

        return maxi;
    }


    private void dfs(int grid[][], int i, int j, int m, int n, int a[], boolean vis[][])
    {


        if(i < 0 || j < 0 || i >= m || j >= n || grid[i][j] == 0 || vis[i][j])
        {
            return;
        }
        vis[i][j] = true;

        a[0] += grid[i][j];

        dfs(grid, i+1, j, m, n, a, vis);

        dfs(grid, i, j+1, m, n, a, vis);

        dfs(grid, i, j-1, m, n, a, vis);

        dfs(grid, i-1, j, m, n, a, vis);
    }
}
```
# Method 2
# Adding values of a matrix concept

# Complexity
- Time complexity: $$O(m*n)$$

- Space complexity: $$O(m*n)$$ recursive stack space

# Code
```java []
class Solution {
    public int findMaxFish(int[][] grid) {

        int m = grid.length, n = grid[0].length;

        int maxi = 0;

        for(int i = 0; i < m; i++)
        {
            for(int j = 0; j < n; j++)
            {
                if(grid[i][j] != 0)
                {

                    maxi = Math.max(maxi, dfs(grid, i, j, m, n));

                }
            }
        }

        return maxi;
    }


    private int dfs(int grid[][], int i, int j, int m, int n)
    {


        if(i < 0 || j < 0 || i >= m || j >= n || grid[i][j] == 0)
        {
            return 0;
        }


        int sum = grid[i][j];

        grid[i][j] = 0;
        
        sum += dfs(grid, i+1, j, m, n);

        sum += dfs(grid, i, j+1, m, n);

        sum += dfs(grid, i, j-1, m, n);

        sum += dfs(grid, i-1, j, m, n);

        return sum;
    }
}
```
['Array', 'Depth-First Search', 'Union Find', 'Matrix', 'Java']