3033. 修改矩阵
题目链接:3033. 修改矩阵
代码如下:
class Solution
{
public:vector<vector<int>> modifiedMatrix(vector<vector<int>>& matrix) {vector<int> maxRows(matrix[0].size());for(int j=0;j<matrix[0].size();j++){for(int i=0;i<matrix.size();i++){maxRows[j]=max(maxRows[j],matrix[i][j]);}for(int i=0;i<matrix.size();i++){if(matrix[i][j]==-1){matrix[i][j]=maxRows[j];}}}return matrix;}
};