Max Number in RUBY!
IntuitionWhen I first saw this problem, I realized that since the fisher can move to any adjacent water cell and collect fish multiple times, we need to find co
# Intuition
When I first saw this problem, I realized that since the fisher can move to any adjacent water cell and collect fish multiple times, we need to find connected components of water cells and sum up all fish in each component. The answer would be the maximum sum among all components.

# Approach
1. **Iterate Through Grid**:
   - For each cell that contains fish (value > 0)
   - Start a DFS to explore all connected water cells

2. **DFS Implementation**:
   - Keep track of visited cells to avoid counting twice
   - Add current cell's fish to total
   - Explore all 4 adjacent cells recursively
   - Return total fish collected in this component

3. **Track Maximum**:
   - Keep track of maximum fish found across all starting positions
   - Return final maximum

# Complexity
- Time complexity: $$O(m * n * 4^{m*n})$$
  - For each cell, we might explore entire grid
  - Each cell has 4 possible directions
  - In practice, much faster due to visited array

- Space complexity: $$O(m * n)$$
  - Visited array for each DFS
  - Recursion stack depth

# Code
```ruby
# @param {Integer[][]} grid
# @return {Integer}
def find_max_fish(grid)
    m, n = grid.length, grid[0].length
    max_fish = 0
    
    # For each water cell
    (0...m).each do |i|
        (0...n).each do |j|
            next if grid[i][j] == 0
            # Start DFS from this cell
            visited = Array.new(m) { Array.new(n, false) }
            max_fish = [max_fish, dfs(grid, i, j, visited)].max
        end
    end
    
    max_fish
end

def dfs(grid, row, col, visited)
    return 0 if row < 0 || row >= grid.length || 
                col < 0 || col >= grid[0].length ||
                visited[row][col] || grid[row][col] == 0
    
    visited[row][col] = true
    total = grid[row][col]
    
    # Try all 4 directions
    dirs = [[0,1], [1,0], [0,-1], [-1,0]]
    dirs.each do |dx, dy|
        new_row = row + dx
        new_col = col + dy
        total += dfs(grid, new_row, new_col, visited)
    end
    
    total
end
```
['Ruby']