Java Clean - BFS
\nclass Solution {\n\n    int[][] nexts=new int[][]{{0,1},{0,-1},{1,0},{-1,0}};\n\n    public int[][] highestPeak(int[][] isWater) {\n        \n        int m=is
```\nclass Solution {\n\n    int[][] nexts=new int[][]{{0,1},{0,-1},{1,0},{-1,0}};\n\n    public int[][] highestPeak(int[][] isWater) {\n        \n        int m=isWater.length;\n        int n=isWater[0].length;\n        \n        boolean[][] visited=new boolean[m][n];\n        Queue<int[]> q=new LinkedList<>();\n        \n        for(int i=0;i<m;i++){\n            for(int j=0;j<n;j++) {\n\n                if(isWater[i][j]==0) continue;    \n\n                q.add(new int[]{i,j});\n                visited[i][j]=true;\n                isWater[i][j]=0;\n\n            }\n        }\n        \n        while(!q.isEmpty()) {\n            \n            int[] cell=q.poll();\n            int r=cell[0], c=cell[1], val=isWater[r][c];\n            \n            for(int[] next:nexts) {\n\n                int x=r+next[0];\n                int y=c+next[1];\n                \n                if(!isValid(x,y,m,n) || visited[x][y]) continue;\n                \n                isWater[x][y]=val+1;\n                visited[x][y]=true;\n                q.add(new int[]{x,y});\n            }\n            \n        }\n        \n        return isWater;\n        \n    }\n    \n    boolean isValid(int r, int c, int m, int n) {\n        return r>=0 && r<m && c>=0 && c<n;\n    }\n}\n```
[]