Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add solutions to lc problem: No.3033 #2337

Merged
merged 13 commits into from
Feb 11, 2024
Merged
Next Next commit
feat: add solutions to lc problem: No.3032
  • Loading branch information
Nothing-avil authored Feb 11, 2024
commit fae01f77bbfe6ee9700b2db54b1475f44567a460
19 changes: 19 additions & 0 deletions solution/3000-3099/3033.Modify the Matrix/Solution.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class Solution {
public:
vector<vector<int>> modifiedMatrix(vector<vector<int>>& matrix) {
int r = matrix.size();
int c = matrix[0].size();
for (int i = 0; i < c; i++) {
int maxs = INT_MIN;
for (int j = 0; j < r; j++) {
maxs = max(maxs, matrix[j][i]);
}
for (int j = 0; j < r; j++) {
if (matrix[j][i] == -1) {
matrix[j][i] = maxs;
}
}
}
return matrix;
}
};