← All problems

Max Area of Island

medium

You're given a 2D grid of 1s (land) and 0s (water), where an island is a group of 1s connected horizontally or vertically. Return the area (cell count) of the largest island, or 0 if there is none.

Same flood-fill walk as Number of Islands, except now you count cells per island instead of just counting islands.

Example

Input: grid = [[1,1,0],[0,1,0],[0,0,1]]
Output: 3
Loading...