Solution
IntuitionEach cell in the isWater matrix is either 0 (land) or 1 (water).
Water cells (1) have height 0.
Adjacent cells differ in height by at most 1
ApproachUs
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
Each cell in the isWater matrix is either 0 (land) or 1 (water).
- Water cells (1) have height 0.
- Adjacent cells differ in height by at most 1

# Approach
<!-- Describe your approach to solving the problem. -->
Used Breadth-First Search (BFS). BFS ensures that cells are visited level by level, making it perfect for assigning heights incrementally outward from water cells.
Started by initializing all water cells with height 0 and mark all other cells as unvisited (-1).

# Complexity
- Time complexity:O(m×n)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:O(m×n)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```python3 []
class Solution:
    def highestPeak(self, isWater: List[List[int]]) -> List[List[int]]:
        m, n = len(isWater), len(isWater[0])
        heights = [[-1] * n for _ in range(m)] 
        queue = deque()
        directions = [(0, 1), (1, 0), (0, -1), (-1, 0)]      
        for i in range(m):
            for j in range(n):
                if isWater[i][j] == 1:
                    heights[i][j] = 0
                    queue.append((i, j))      
        while queue:
            x, y = queue.popleft()
            for dx, dy in directions:
                nx, ny = x + dx, y + dy
                if 0 <= nx < m and 0 <= ny < n and heights[nx][ny] == -1:
                    heights[nx][ny] = heights[x][y] + 1
                    queue.append((nx, ny))
        return heights
```
['Python3']