g3001_3100.s3033_modify_the_matrix.Solution Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of leetcode-in-java Show documentation
Show all versions of leetcode-in-java Show documentation
Java-based LeetCode algorithm problem solutions, regularly updated
The newest version!
package g3001_3100.s3033_modify_the_matrix;
// #Easy #Array #Matrix #2024_03_01_Time_1_ms_(100.00%)_Space_45.4_MB_(77.37%)
public class Solution {
public int[][] modifiedMatrix(int[][] matrix) {
for (int i = 0; i < matrix.length; i++) {
for (int j = 0; j < matrix[0].length; j++) {
if (matrix[i][j] == -1) {
int y = 0;
for (int[] ints : matrix) {
if (ints[j] > y) {
y = ints[j];
}
}
matrix[i][j] = y;
}
}
}
return matrix;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy