Tap here to switch tabs
Problem
Submissions

Problem: Maximum Number of Fish in a Grid

Try to solve the Maximum Number of Fish in a Grid problem.

Statement

You are given a 00 indexed two dimensional integer array grid of size m ×\times n, where:

  • grid[r][c] = 00 represents a land cell.

  • grid[r][c] > 00 represents a water cell containing grid[r][c] fish.

A fisher can start at any water cell (r, c) and perform the following operations:

  • Catch all the fish at the current cell (r, c).

  • Move to any adjacent water cell in the four cardinal directions (up, down, left, or right).

The fisher can continue moving to adjacent water cells that have not yet been visited.

Return the maximum number of fish the fisher can collect. If there are no water cells in grid, return 00.

Constraints:

  • m == grid.length

  • n == grid[i].length

  • 1≤1 \leq m, n ≤10\leq 10

  • 0≤0 \leq grid[i][j] ≤10\leq 10

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Number of Fish in a Grid

Try to solve the Maximum Number of Fish in a Grid problem.

Statement

You are given a 00 indexed two dimensional integer array grid of size m ×\times n, where:

  • grid[r][c] = 00 represents a land cell.

  • grid[r][c] > 00 represents a water cell containing grid[r][c] fish.

A fisher can start at any water cell (r, c) and perform the following operations:

  • Catch all the fish at the current cell (r, c).

  • Move to any adjacent water cell in the four cardinal directions (up, down, left, or right).

The fisher can continue moving to adjacent water cells that have not yet been visited.

Return the maximum number of fish the fisher can collect. If there are no water cells in grid, return 00.

Constraints:

  • m == grid.length

  • n == grid[i].length

  • 1≤1 \leq m, n ≤10\leq 10

  • 0≤0 \leq grid[i][j] ≤10\leq 10