🌊 BFS Flood: From Water to Peaks! | Beginner's Friendly Code⚡
IntuitionWe treat all water cells as sources (height = 0) and use multi-source BFS to assign increasing height values to land cells. Each land cell gets its hei
# Intuition
We treat all water cells as sources (height = 0) and use multi-source BFS to assign increasing height values to land cells. Each land cell gets its height based on the shortest distance from any water cell. BFS ensures we process all nearby cells first, so heights increase correctly.

# Approach
<!-- Describe your approach to solving the problem. -->

# 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
```java []
class Solution {
    public int[][] highestPeak(int[][] isWater) {
        Queue<int[]> q = new LinkedList<>();
        int m = isWater.length, n = isWater[0].length;
        boolean[][] vis = new boolean[m][n];
        int[][] dir = {{0,1},{0,-1},{1,0},{-1,0}};
        for(int i = 0; i < m; i++) {
            for(int j = 0; j < n; j++) {
                if(isWater[i][j] == 1) {
                    q.add(new int[]{i, j});
                    isWater[i][j] = 0;
                    vis[i][j] = true;
                }
            }
        }
        int level = 1;
        while(!q.isEmpty()) {
            int size = q.size();
            for(int s = 0; s < size; s++) {
                int[] p = q.poll();
                int i = p[0], j = p[1];
                for(int[] d : dir) {
                    int x = i + d[0], y = j + d[1];
                    if(x >= 0 && x < m && y >= 0 && y < n && !vis[x][y]) {
                        vis[x][y] = true;
                        isWater[x][y] = level;
                        q.add(new int[]{x, y});
                    }
                }
            }
            level++;
        }
        return isWater;
    }
}
```
['Breadth-First Search', 'Queue', 'Java']