DFS | BFS | 0ms - 100% | 8.04MB - 100%
DFSBFS
![Screenshot 2025-01-28 at 7.42.33 AM.png](https://assets.leetcode.com/users/images/60ef4877-664a-4ff8-af6a-ed306c246c44_1738030443.0416255.png)
![Screenshot 2025-01-28 at 7.42.39 AM.png](https://assets.leetcode.com/users/images/ee083dea-c16c-45aa-a34c-5ee21123dce6_1738030450.1468494.png)

# DFS
```golang []
func findMaxFish(grid [][]int) int {
	var (
		dfs      func(int, int) int
		maxCatch int
	)

	dfs = func(row, col int) int {
		if row < 0 || col < 0 || row == len(grid) || col == len(grid[0]) || grid[row][col] == 0 {
			return 0
		}

		fish := grid[row][col]
		grid[row][col] = 0
		return fish + dfs(row, col+1) + dfs(row+1, col) + dfs(row-1, col) + dfs(row, col-1)
	}

	for row := 0; row < len(grid); row++ {
		for col := 0; col < len(grid[0]); col++ {
			maxCatch = max(maxCatch, dfs(row, col))
		}
	}
	return maxCatch
}
```

# BFS 
```
func findMaxFish(grid [][]int) int {
	var (
		maxCatch            int
		q                   [][2]int
		currSum, r, c, cell = 0, 0, 0, [2]int{}
	)

	for row := 0; row < len(grid); row++ {
		for col := 0; col < len(grid[0]); col++ {
			if grid[row][col] == 0 {
				continue
			}
			q = q[:0]
			q = append(q, [2]int{row, col})
			currSum = 0
			for len(q) > 0 {
				cell = q[len(q)-1]
				q = q[:len(q)-1]
				r = cell[0]
				c = cell[1]
				if r < 0 || c < 0 || r == len(grid) || c == len(grid[0]) || grid[r][c] == 0 {
					continue
				}
				currSum += grid[r][c]
				grid[r][c] = 0
				q = append(q, [2]int{r, c + 1})
				q = append(q, [2]int{r + 1, c})
				q = append(q, [2]int{r - 1, c})
				q = append(q, [2]int{r, c - 1})
			}
			maxCatch = max(maxCatch, currSum)
		}
	}
	return maxCatch
}
```
['Depth-First Search', 'Go']