Practice Map of Highest Peak
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
isWater uses 1 for water and 0 for land. Assign a nonnegative integer height to every cell, with water cells fixed at 0. Heights of horizontally or vertically adjacent cells may differ by at most 1. Maximize the highest assigned height and return any height matrix achieving it.
Source: Map of Highest Peak on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
isWater = [[0,1],[0,0]]
Output
[[1,0],[2,1]]
# Example 2
Input
isWater = [[0,0,1],[1,0,0],[0,0,0]]
Output
[[1,1,0],[0,1,1],[1,2,2]]
Constraints
m == isWater.length
n == isWater[i].length
1 <= m, n <= 1000
isWater[i][j] is 0 or 1.
There is at least one water cell.
Related LeetCode Problems
Practice more problems similar to Map of Highest Peak.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.