Table of contents
topic
Title description
Given a two-dimensional grid consisting of numbers greater than 0 (land) and 0 (water), please calculate the volume of the largest island in the grid. The number of land represents the volume of the island where it is located.Islands are always surrounded by water, and each island can only be formed by connecting horizontally and/or vertically adjacent land.
Also, you can assume that the mesh is surrounded by water on all four sides.
Input Description
The first line is the width and height of the 2D grid.
The next few lines are the 2D grid.Output Description
Outputs the maximum volume of the island.Example
Input
5 5
0 1 1 0 0
0 1 1 0 0 0
0 0 0 0 0
0 1 2 3
0 0 1 3 9
Output
19
train of thought
1: