BFS || C++ || ✅Easy Solution
Approach\nSimple BFS approach.\nEnter in a cell when grid[r][c]!=0 and search in neighbours cell using bfs whenever leaving that particular cell add this to our
# Approach\nSimple BFS approach.\nEnter in a cell when grid[r][c]!=0 and search in neighbours cell using bfs whenever leaving that particular cell add this to our fish variable and put it equal to 0 that is grid[r][c]=0.\n\n# Complexity\n- Time complexity:\n  O(n*m)\n\n- Space complexity:\n  O(min(n,m))\n\n# Code\n```\nclass Solution {\npublic:\n    int findMaxFish(vector<vector<int>>& grid) {\n        int n=grid.size(),m=grid[0].size();\n        vector<int> v={0,-1,0,1,0};\n        int ans=0,mx=0;\n         for(int i=0;i<n;i++)\n        {\n            for(int j=0;j<m;j++)\n            {\n                ans=0;\n                if(grid[i][j]!=0)\n                {\n                    queue<pair<int,int>> q;\n                    q.push({i,j});\n                    ans+=grid[i][j];\n                    grid[i][j]=0;\n                    while(!q.empty())\n                    {\n                        for(int k=0;k<4;k++)\n                        {\n                            int r1=q.front().first+v[k];\n                            int c1=q.front().second+v[k+1];\n                            if(r1>=0 && r1<n && c1>=0 && c1<m && grid[r1][c1]!=0)\n                            {\n                                ans+=grid[r1][c1];\n                                q.push({r1,c1});\n                                grid[r1][c1]=0;\n                            }\n                        }\n                        q.pop();\n                    }\n                }\n                 mx=max(mx,ans);\n            }\n         }\n        return mx;\n    }\n};\n```
['C++']