Problem
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.
Example 1
[[0, 1, 1, 0],
Example 2
[0, 1, 0, 0],
Example 3
[1, 0, 0, 1],
Example 4
- Input
- [1, 1, 0, 1]]
- Output
- 3
Example 5
- Input
- [[0, 0, 0]]
- Output
- 0
Constraints
1 <= grid.length, grid[i].length <= 50grid[i][j] is 0 or 1You may change the grid.