Given a 2D boolean array where true represents water and false represents land, generate a grid with the highest possible peak.
Rules are:
- The height of any water cell is 0.
- The height of any land cell cannot differ for more than one from any of the neighboring (sharing one edge) cells.
Example:
Input:
[[T, F, T],
[F, F, F],
[F, F, F]]
One possible grid is
[[0, 0, 0],
[1, 0, 1],
[2, 1, 2]]
And grid
[[0, 2, 0],
[0, 0, 0],
[0, 0, 0]]
Output:
[[0, 1, 0],
[1, 2, 1],
[2, 3, 2]]
Where the highest peak is 3. Hint – Use BSF