c++ DFS
\n# Code\n\nclass Solution {\n    void dfs(int row, int col, vector<vector<int>>& grid, vector<vector<int>>& vis, int &fish) {\n        int n = grid.size(), m =
\n# Code\n```\nclass Solution {\n    void dfs(int row, int col, vector<vector<int>>& grid, vector<vector<int>>& vis, int &fish) {\n        int n = grid.size(), m = grid[0].size(); \n        vis[row][col] = 1;\n        fish += grid[row][col];\n        int r_dir[4] = {-1, 0, 1, 0};\n        int c_dir[4] = {0, 1, 0, -1};\n        for(int i = 0; i < 4; i++) {\n            int r = row + r_dir[i];\n            int c = col + c_dir[i];\n            if(r >= 0 && r < n && c >= 0 && c < m && grid[r][c] && !vis[r][c]) {\n                dfs(r, c, grid, vis, fish);\n            }\n        }\n    }\npublic:\n    int findMaxFish(vector<vector<int>>& grid) {\n        int n = grid.size(), m = grid[0].size();\n        vector<vector<int>> vis(n, vector<int>(m, 0));\n        int max_fish = 0;\n        for(int i = 0; i < n; i++) {\n            for(int j = 0; j < m; j++) {\n                if(grid[i][j] > 0 && !vis[i][j]) {\n                    int fish = 0;\n                    dfs(i, j, grid, vis, fish);\n                    max_fish = max(max_fish, fish);\n                }\n            }\n        }\n        return max_fish;\n    }\n};\n```
['Depth-First Search', 'C++']