You are given an m x n binary matrix grid. An island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical). You may assume all four edges of the grid are surrounded by water.
The area of an island is the number of cells with a value 1 in the island.
Return the maximum area of an island in grid. If there is no island, return 0.
Example 1:
Input: grid = [[0,0,1,0,0,0,0,1,0,0,0,0,0],[0,0,0,0,0,0,0,1,1,1,0,0,0],[0,1,1,0,1,0,0,0,0,0,0,0,0],[0,1,0,0,1,1,0,0,1,0,1,0,0],[0,1,0,0,1,1,0,0,1,1,1,0,0],[0,0,0,0,0,0,0,0,0,0,1,0,0],[0,0,0,0,0,0,0,1,1,1,0,0,0],[0,0,0,0,0,0,0,1,1,0,0,0,0]]
Output: 6
Explanation: The largest island has area 6 (the group of 1's in the bottom-right region).
Example 2:
Input: grid = [[0,0,0,0,0,0,0,0]]
Output: 0
Explanation: There are no islands, so the answer is 0.
Example 3:
Input: grid = [[1,1],[1,0]]
Output: 3
Explanation: The three connected 1's form a single island with area 3.
m == grid.lengthn == grid[i].length1 <= m, n <= 50grid[i][j] is either 0 or 1