We’re preparing your current view and syncing the latest data.
You are given an m x n integer matrix isWater that represents a map of land and water cells.
If isWater[i][j] == 1, cell (i, j) is a water cell. If isWater[i][j] == 0, cell (i, j) is a land cell.
The height of each cell is determined by the following rules:
Return an m x n integer matrix heightMap where heightMap[i][j] is the height of the cell (i, j).
Note: The height of the highest peak should be maximized.
A 2D integer matrix isWater of size m x n where:
Return a 2D integer matrix heightMap of size m x n where heightMap[i][j] represents the height of the cell (i, j).
m == isWater.length n == isWater[i].length 1 <= m, n <= 1000 isWater[i][j] is either 0 or 1 There is at least one water cell in the grid.
Example 1
Input
[[0,1],[0,0]]
Output
[[1,0],[2,1]]
Explanation
Starting from the water cell (0,1) which has height 0, adjacent land cells (0,0) has height 1, (1,1) has height 1, and (1,0) has height 2.