Problem
You get a grid grid with m rows and n columns. Each cell is 1 for land or 0 for water.
An island is a group of land cells that connect horizontally or vertically. Cells that touch only at a corner do not connect. The area of an island is the number of cells in it.
Return the largest area of an island in grid. If grid has no land, return 0.
Example 1
- Input:
- grid = [[1,1,0,0,1],[1,0,0,1,1],[0,0,0,0,1],[0,1,1,0,0]]
- Output:
- 4
- Explanation:
- The island at the right edge has 4 cells. The other two islands have 3 cells and 2 cells.
Example 2
- Input:
- grid = [[0,0],[0,0]]
- Output:
- 0
Example 3
- Input:
- grid = [[1,0],[0,1]]
- Output:
- 1
- Explanation:
- The two land cells touch only at a corner. Each cell is a separate island with an area of 1.
Constraints
- m == grid.length
- n == grid[i].length
- 1 <= m, n <= 50
- grid[i][j] is 0 or 1
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 4 records
Amazon
Leetcode 695. Max Area of Island
Reported Dec 11, 2024 · 1 source report
MID_LEVEL
Source snapshot: Nov 12, 2026
View sourceLinkedIn
Leetcode 695. Max Area of Island
Reported Oct 9, 2025 · 1 source report
SENIOR
Source snapshot: Nov 12, 2026
View sourceMeta
Leetcode 695. Max Area of Island
Reported Mar 19, 2025 · 2 source reports
MID_LEVEL, STAFF
Source snapshot: Nov 12, 2026
View sourceOracle
Leetcode 695. Max Area of Island
Reported Dec 10, 2025 · 1 source report
SENIOR
Source snapshot: Nov 12, 2026