Maximum Area of an Island in a Grid

Asked at Flexport · Coding Questions · Difficulty: Medium · Last asked Nov 6, 2026

A map of a region is stored as a rectangular grid in which `1` marks land and `0` marks water. A land cell belongs to the same island as every land cell it touches directly above, below, left or right; diagonal neighbours do not connect. The area of an island is its number of cells. Find the area of the largest island on the map.

Loading the problem…