Max Area of Island
Problem
You are given a grid of 0s and 1s. A cell with value 1 is land; an island is a maximal group of land cells connected by up/down/left/right moves. The area of an island is the number of cells in it. Return the area of the largest island, or 0 if there is no land.
- The grid has between 1 and 60 rows and between 1 and 60 columns.
- Each cell is the integer
0or1.
Examples
grid = [[1,1,0,0,1],[0,1,0,1,1],[0,0,0,1,0],[1,0,0,1,0]]→5. Three islands: the top-left cluster has 3 cells, the bottom-left corner is a lone cell, and the cluster snaking down the right side has 5.grid = [[0,1,0],[1,1,1],[0,1,0]]→5. A plus sign is one island of five cells.grid = [[0,0],[0,0]]→0. No land.
Hints
- This is Number of Islands, except that instead of counting islands you need to measure each one.
- A flood fill naturally visits every cell of one island exactly once. What does its return value need to be?
- DFS/BFS from each unvisited land cell, have the fill return the number of cells it consumed, and keep the running maximum.
Last reviewed 8 September 2026
Approach · Solution (Python) · Complexity · Follow-ups · Company variations · Tests
The rest of this question — the worked approach, the Python solution with passing tests, complexity, follow-ups and how each company frames it — is part of the guides.
Get the full guide
Pick the company you're interviewing with. Each guide has every question tiered for that loop — one-time purchase, lifetime access.
Also in: Apple, Google, Meta, Microsoft, Netflix
Interviewing at more than one? All 6 guides for $499 · save $395
Not ready to buy? Get the free starter pack — 13 questions with full solutions.