← 返回 uber 的题目列表Number of Islands 1&2 Combined
类型:online_judge
Given a m x n 2D grid made up of '1's (land) and '0's (water), calculate the number of islands and the maximum area of each island. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water.
Input format:
A 2D character grid of size m x n grid
Output format:
Integers representing the number of islands and the maximum area of the islands.
Example 1:
Input: grid = ["11000","11000","00100","00011"]
Output: Number of islands = 3, Maximum area = 4
Constraints:
1 <= m, n <= 300
grid[i][j] is '0' or '1'
Example
Input
"11000\n11000\n00100\n00011"