C++| Dp | 100% Faster and 100% Less Space | Easy
\nclass Solution {\npublic:\n    vector<vector<int>> highestPeak(vector<vector<int>>&a) {\n        int n=a.size();\n        int m=a[0].size();\n        vector<v
```\nclass Solution {\npublic:\n    vector<vector<int>> highestPeak(vector<vector<int>>&a) {\n        int n=a.size();\n        int m=a[0].size();\n        vector<vector<int>>dp(n,vector<int>(m,INT_MAX-1000));\n        for(int i=0;i<n;i++)\n            for(int j=0;j<m;j++)\n            {\n                if(a[i][j]==1)\n                    dp[i][j]=0;\n                else\n                {\n                    if(i>0)\n                        dp[i][j]=min(dp[i][j],dp[i-1][j]+1);\n                    if(j>0)\n                        dp[i][j]=min(dp[i][j],dp[i][j-1]+1);\n                }\n            }\n        for(int i=n-1;i>=0;i--)\n            for(int j=m-1;j>=0;j--)\n            {\n                if(i<n-1)\n                   dp[i][j]=min(dp[i][j],dp[i+1][j]+1); \n                if(j<m-1)\n                   dp[i][j]=min(dp[i][j],dp[i][j+1]+1);\n            }\n        return dp;\n    }\n};\n```
['Dynamic Programming', 'C']