Given a 2D grid of 0s and 1s, return the maximum area of any island. The area of an island is the number of 1-cells in its connected component. Pattern focus: DFS. Explore each island fully and keep track of the largest component size found.
grid = 2D binary matrix
maximum island area
Example 1:
Input:
grid = [[0,0,1,0,0],[1,1,1,0,0],[0,1,0,0,1],[0,0,0,1,1]]
Output:
5
Explanation:
The largest connected island has 5 cells.
Example 2:
Input:
grid = [[0,0,0],[0,0,0]]
Output:
0
Explanation:
There is no island.
Example 3:
Input:
grid = [[1]]
Output:
1
Explanation:
A single land cell has area 1.