C++ || BFS approach || TC O(N^2)
Approach
Start bfs with water and change its height to 0.
Keep traversing and adding 1 after every layer to maximize the height.
When all indices are visited re
# Approach
<!-- Describe your approach to solving the problem. -->
- Start bfs with water and change its height to 0. 
- Keep traversing and adding 1 after every layer to maximize the height. 
- When all indices are visited return the heights of all indices

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

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

# Code
```cpp []
class Solution {
public:
    bool isValid(int i, int j, int m, int n) {return i>=0 && i<m && j>=0 && j<n;}
    vector<vector<int>> highestPeak(vector<vector<int>>& isWater) {
        queue<pair<int,int>> q;
        int m=isWater.size(), n=isWater[0].size();
        vector<vector<bool>> vis(m, vector<bool>(n, false));
        for(int i=0; i<m; i++){
            for(int j=0; j<n; j++){
                if(isWater[i][j]==1) isWater[i][j]=0, q.push({i,j}), vis[i][j]=true;
            }
        }
        vector<vector<int>> dir{{-1,0}, {1,0}, {0,1}, {0,-1}};
        while(!q.empty()){
            int size=q.size();
            for(int k=0; k<size; k++){
                pair<int, int> curr=q.front();
                int i=curr.first, j=curr.second;
                q.pop();
                for(auto& d: dir){
                    int ni=i+d[0], nj=j+d[1];
                    if(isValid(ni, nj, m, n) && !vis[ni][nj]){
                        q.push({ni, nj});
                        isWater[ni][nj]=isWater[i][j]+1;
                        vis[ni][nj]=true;
                    }
                }
            }
        }
        return isWater;
    }
};
```
['Array', 'Breadth-First Search', 'Matrix', 'C++']