🐟 Maximum Fish Catch 🚀 | Easy DFS Solution | Python 🧠 | Dive Into the Grid 🌊
IntuitionThe problem can be thought of as finding the largest connected "pool" of fish in the grid, where we traverse all possible water cells (non-zero values)
# Intuition  
The problem can be thought of as finding the largest connected "pool" of fish in the grid, where we traverse all possible water cells (non-zero values) starting from each cell. Depth First Search (DFS) is a suitable approach to explore connected components in the grid.  

# Approach  
1. Use DFS to explore all connected water cells starting from a given water cell `(r, c)`.  
2. While visiting each cell, sum up the fish in the cell and mark it as visited by setting its value to `0` (to avoid revisiting).  
3. Repeat this process for every cell in the grid. For each starting cell, compute the total fish collected and track the maximum.  
4. If no water cells exist, return `0`.  

### If you find this explanation helpful, please consider upvoting! 😊

# Complexity  
- **Time complexity**:  
  $$O(m \times n)$$  
  Each cell is visited once during the DFS traversal.  
- **Space complexity**:  
  $$O(m \times n)$$  
  For the recursion stack in the worst case.  

# Code  
```python
class Solution:
    def findMaxFish(self, grid: List[List[int]]) -> int:
        def dfs(i: int, j: int) -> int:
            if i < 0 or i == len(grid) or j < 0 or j == len(grid[0]):
                return 0
            if grid[i][j] == 0:
                return 0
            
            caughtfish = grid[i][j]
            grid[i][j] = 0
            return (caughtfish + dfs(i+1, j) + dfs(i-1, j) + dfs(i, j+1) + dfs(i, j-1))

        return max(dfs(i, j) for i in range(len(grid)) for j in range(len(grid[0])))
```
['Depth-First Search', 'Python3']