pond. A cell holding 0 is land; a cell holding a positive value is water, and the value is the number of fish in it.
A fisher picks any water cell to start from. From there they may step into an adjacent water cell (up, down, left or right; not diagonally) and catch all the fish in every cell they visit. Land cannot be crossed.
Return the largest number of fish that can be caught with the best choice of starting cell, or 0 if the map has no water.pond=[[3, 0, 2], [1, 0, 5], [0, 4, 0]] → 7
There are three lakes: cells 3 and 1 give 4 fish, cells 2 and 5 give 7, and the lone cell at the bottom gives 4. The best catch is 7.
pond=[[0, 0], [0, 0]] → 0
There is no water at all, so nothing can be caught.
pond=[[1, 2, 0], [0, 3, 0], [6, 0, 0]] → 6
Cells 1, 2 and 3 are connected and give 6. The 6 cell only touches the 3 cell diagonally, so it is a separate lake, also worth 6.
pond[i][j] ≤ 10pond=[[3, 0, 2], [1, 0, 5], [0, 4, 0]]
7
Run checks the first 3 tests in your browser. Submit checks all 101 tests on the server, hidden ones included.