Max Area of Island
Return the size of the largest orthogonally connected component of ones in a binary integer grid, or zero when there is no land.
Example 1
0,01I1
0,11I1
0,20
1,00
1,11I1
1,20
2,01I2
2,10
2,21I3
grid = [[1,1,0],[0,1,0],[1,0,1]]3Explanation
The top-left component has three cells; both bottom corner cells are isolated.
Example 2
0,00
0,10
grid = [[0,0]]0Explanation
No ones means maximum area zero.
Example 3
0,01I1
grid = [[1]]1Explanation
The sole land cell has area one.
Constraints
- 1 <= rows, columns <= 50
- Cells are integer 0 or 1
Function contract
maxAreaOfIslandArguments: jsonSolutionRuns on your device
Loading draft…
Run: 3 examples; Submit: 34 cases, on your device.
[[1,1,0],[0,1,0],[1,0,1]]