Largest Forest Patch
Medium · Largest Forest Patch
A nature reserve map is a rectangular grid `plan` with m rows and n columns. A cell holds 1 if it is covered by forest and 0 if it is open field. A forest patch is a group of forest cells linked through their top, bottom, left or right neighbours; touching diagonally does not join patches. There is no forest beyond the edges of the map. The size of a patch is the number of cells in it. Return the size of the largest patch, or 0 if the map has no forest.…
Solve the problem →