✅ 🌟 JAVA SOLUTION ||🔥 BEATS 100% PROOF🔥|| 💡 CONCISE CODE ✅ || 🧑‍💻 BEGINNER FRIENDLY
Complexity
Time complexity:O(m * n)

Space complexity:O(m * n)
Code
# 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) {
        int[][] directions={{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
        Queue<int[]> cellQueue=new LinkedList<>();
        int m=isWater.length;
        int n=isWater[0].length;;
        int[][] cellHeights=new int[m][n];
        for(int i=0;i<m;i++)
        {
            for(int j=0;j<n;j++)
            {
                if(isWater[i][j]==1)
                {
                    cellQueue.offer(new int[]{i, j});
                    cellHeights[i][j]=0;
                }
                else
                {
                    cellHeights[i][j]=-1;
                }
            }
        }
        while(!cellQueue.isEmpty())
        {
            int[] curr=cellQueue.poll();
            int row=curr[0];
            int col=curr[1];
            for(int[] dir: directions)
            {
                int newRow=row+dir[0];
                int newCol=col+dir[1];
                if(newRow>=0 && newRow<m && newCol>=0 && newCol<n && cellHeights[newRow][newCol]==-1)
                {
                    cellHeights[newRow][newCol]=cellHeights[row][col]+1;
                    cellQueue.offer(new int[]{newRow, newCol});
                }
            }
        }
        return cellHeights;
    }
}
```
['Array', 'Breadth-First Search', 'Matrix', 'Java']