C++ BFS Solution
Because any two adjacent cells must have an absolute height difference of at most 1, we can apply level order traversal (BFS).\n We will first push indices of w
* Because **any two adjacent cells must have an absolute height difference of at most 1**, we can apply level order traversal (BFS).\n* We will first **push indices of water cells** in the queue.\n* Then while queue is not empty we will pop out cell one by one and **push all neighbour cells** which are not visited in the queue.\n* We will simply store **level** of each cell in our ans vector.\n\n```\nclass Solution {\npublic:\n    vector<vector<int>> highestPeak(vector<vector<int>>& isWater) {\n        int m = isWater.size();\n        int n=isWater[0].size();\n\t\t// 4 Directions\n        vector <int> dirs={0,-1,0,1,0};\n\t\t// Queue to store cell\'s row and column information\n        queue <pair<int,int>> q;\n\t\t// Ans\n        vector <vector <int>> ans(m,vector <int>(n,0));\n\t\t\n        for(int i=0;i<m;i++)\n        {\n            for(int j=0;j<n;j++)\n            {\n\t\t\t// push all water cell in queue\n                if(isWater[i][j]==1)\n                    q.push({i,j});\n            }\n        }\n\t\t// level\n        int l=0;\n        while(!q.empty())\n        {\n            int s=q.size();\n            while(s--)\n            {\n                auto p=q.front();\n                q.pop();\n\t\t\t\t// strore level in each cell\n                ans[p.first][p.second]=l;\n                for(int k=1;k<5;k++)\n                {\n                    int i=p.first+dirs[k-1];\n                    int j=p.second+dirs[k];\n                    if(i>=0&&j>=0&&i<m&&j<n&&isWater[i][j]==0)\n                    {\n\t\t\t\t\t//push cell and make it visited\n                        q.push({i,j});\n                        isWater[i][j]=1;\n                    }\n                }\n            }\n            l++;\n        }\n        return ans;\n    }\n};\n```
['Breadth-First Search', 'C', 'C++']