C# Solution for Map of Highest Peak Problem
IntuitionThe problem can be interpreted as a multi-source shortest path problem:
•	Water cells are sources, and their heights are fixed to 0.
•	Land cells are d
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
The problem can be interpreted as a multi-source shortest path problem:
•	Water cells are sources, and their heights are fixed to 0.
•	Land cells are destinations, and their heights increase with distance from the nearest water cell.
•	The goal is to assign heights in a way that satisfies the adjacency constraints (absolute height difference ≤ 1).

Using Breadth-First Search (BFS) ensures:
1.	Cells closer to water are assigned smaller heights first.
2.	Heights are propagated outward layer by layer, satisfying the adjacency constraint.

# Approach
<!-- Describe your approach to solving the problem. -->
1.	Initialization:
	•	Create a height matrix of size m x n, initialized to -1 (indicating unvisited cells).
	•	Enqueue all water cells (i.e., isWater[i][j] == 1) into a queue. Set their height to 0.
2.	Breadth-First Search (BFS):
	•	BFS starts from all water cells simultaneously.
	•	For each cell in the queue, visit its 4 neighbors (north, south, east, west).
	•	If a neighbor cell is unvisited (height[newX][newY] == -1):
	•	Set its height to the current cell’s height + 1.
	•	Add it to the queue for further processing.
	•	BFS ensures that heights increase gradually as the algorithm progresses outward from water cells.
3.	Termination:
	•	BFS terminates when all land cells are visited, i.e., the queue is empty.
4.	Return Result:
	•	The height matrix now contains the required heights.

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
O(m × n):
•	Each cell in the matrix is visited once during the BFS traversal.
•	For each cell, its 4 neighbors are checked (constant work per cell).
•	Hence, the total time complexity is proportional to the number of cells in the matrix.

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
O(m × n):
•	Queue: The BFS queue can hold up to all cells in the matrix in the worst case, which is O(m × n).
•	Height Matrix: The height matrix requires O(m × n) space.
•	Thus, the total space complexity is O(m × n).

# Code
```csharp []
public class Solution {
    public int[][] HighestPeak(int[][] isWater) {
        int m = isWater.Length;
        int n = isWater[0].Length;
        int[][] height = new int[m][];
        
        for (int i = 0; i < m; i++) {
            height[i] = new int[n];
            Array.Fill(height[i], -1);
        }

        int[][] directions = new int[][] {
            new int[] {-1, 0}, 
            new int[] {1, 0},  
            new int[] {0, -1}, 
            new int[] {0, 1}   
        };

        Queue<(int, int)> queue = new Queue<(int, int)>();

        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (isWater[i][j] == 1) {
                    height[i][j] = 0;
                    queue.Enqueue((i, j)); 
                }
            }
        }

        while (queue.Count > 0) {
            var (x, y) = queue.Dequeue();

            foreach (var dir in directions) {
                int newX = x + dir[0];
                int newY = y + dir[1];

                if (newX >= 0 && newX < m && newY >= 0 && newY < n && height[newX][newY] == -1) {
                    height[newX][newY] = height[x][y] + 1; 
                    queue.Enqueue((newX, newY)); 
                }
            }
        }

        return height;
    }
}
```
['C#']