Max Area of Island
MediumGraphs
Decode it first. Clues, constraints, pattern and plan before any code.A grid holds 1 for land and 0 for water. Land cells connected horizontally or vertically form an island, and its area is the number of cells in it. Return the area of the largest island, or 0 if there is no land.
[[0, 1, 1, 0],
[0, 1, 0, 0],
[1, 0, 0, 1],
[1, 1, 0, 1]] → 3
[[0, 0, 0]] → 0Constraints
1 <= grid.length, grid[i].length <= 50grid[i][j]is0or1- You may change the grid.