← 返回 bytedance 的题目列表Max Area of Island
类型:online_judge
Max Area of Island
Given a grid of '1's (land) and '0's (water), find the maximum area of an island in the grid. An island is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are surrounded by water.
Input: A 2D integer array grid representing the map with 1 (land) and 0 (water).
Output: An integer representing the maximum area of an island.
Constraints:
The size of the grid does not exceed 50x50.
Example:
Input:
[[0,0,1,0,0],
[1,1,1,1,0],
[0,1,0,0,1],
[0,0,0,1,1]]
Output: 5
Example
Input
[[0,0,1,0,0],[1,1,1,1,0],[0,1,0,0,1],[0,0,0,1,1]]