Beats 94.22% || BFS                   ||||   AVS

```cpp []
class Solution {
public:
    vector<vector<int>> highestPeak(vector<vector<int>>& a) {
        int n = a.size();
        int m = a[0].size();
        vector<vector<int>> ans(n, vector<int>(m, 1e9));
        queue<pair<int, int>> q;
        
        for (int i = 0; i < n; i++) 
            for (int j = 0; j < m; j++) 
                if (a[i][j]) {
                    ans[i][j] = 0;
                    q.push({i, j});
                }
      
      
        while (!q.empty()) {
            int i = q.front().first;
            int j = q.front().second;
            q.pop();
            
            if (i + 1 < n && ans[i + 1][j] > ans[i][j] + 1) {
                ans[i + 1][j] = ans[i][j] + 1;
                q.push({i + 1, j});
            }
            if (j + 1 < m && ans[i][j + 1] > ans[i][j] + 1) {
                ans[i][j + 1] = ans[i][j] + 1;
                q.push({i, j + 1});
            }
            if (i - 1 >= 0 && ans[i - 1][j] > ans[i][j] + 1) {
                ans[i - 1][j] = ans[i][j] + 1;
                q.push({i - 1, j});
            }
            if (j - 1 >= 0 && ans[i][j - 1] > ans[i][j] + 1) {
                ans[i][j - 1] = ans[i][j] + 1;
                q.push({i, j - 1});
            }
        }
        
        return ans;
    }
};

```
['Breadth-First Search', 'Matrix', 'C++']