Algorithm · Dropbox · Hard
You are given a square binary matrix grid with side length $$n$$. A cell holding 1 is dry land, while a cell holding 0 is water. Two land cells are part of the same island if one can reach the other by moving only upward, downward, leftward, or rightward through other land cells. You may change no more than one water cell into a land cell. Across all such choices, return the largest possible number of cells in a single island. Your algorithm must run in $$O(n^2)$$ time and…
Checking your access…