✔💯 DFS || MOST SIMPLE SOLUTION|| C++
\n\nclass Solution {\npublic:\n    void solve(int i,int j,int &a,int &b,int &sum,int &ans,vector<vector<int>> &g){\n        ans = max(ans,sum);\n        if(i<0|
\n````\nclass Solution {\npublic:\n    void solve(int i,int j,int &a,int &b,int &sum,int &ans,vector<vector<int>> &g){\n        ans = max(ans,sum);\n        if(i<0||j<0||i>=a||j>=b||g[i][j]==0){\n            return;\n        }\n        sum += g[i][j];\n        g[i][j] = 0;\n        solve(i+1,j,a,b,sum,ans,g);\n        solve(i,j+1,a,b,sum,ans,g);\n        solve(i-1,j,a,b,sum,ans,g);\n        solve(i,j-1,a,b,sum,ans,g);\n    }\n    int findMaxFish(vector<vector<int>>& grid) {\n        int ans = 0;\n        int i,j,a = grid.size(),b = grid[0].size();\n        int sum = 0;\n        for(i = 0; i < a; i++){\n            for(j = 0; j < b; j++){\n                if(grid[i][j]){\n                    sum = 0;\n                    solve(i,j,a,b,sum,ans,grid);\n                }\n            }\n        }\n        return ans;\n    }\n};\n````\n\n
['Depth-First Search', 'Graph', 'C', 'C++']