We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent da301b8 commit bd7fef4Copy full SHA for bd7fef4
solution/0073.Set Matrix Zeroes/Solution.java
@@ -0,0 +1,20 @@
1
+class Solution {
2
+ public void setZeroes(int[][] matrix) {
3
+ int matrixRow = matrix.length, matrixCol = matrix[0].length;
4
+ boolean[] row = new boolean[matrixRow], col = new boolean[matrixCol];
5
+ for (int i = 0; i < matrixRow; i++) {
6
+ for (int j = 0; j < matrixCol; j++) {
7
+ if (matrix[i][j] == 0) {
8
+ row[i] = true;
9
+ col[j] = true;
10
+ }
11
12
13
14
+ if (row[i]) for (int k = 0; k < matrixCol; k++) matrix[i][k] = 0;
15
16
17
+ if (col[j]) for (int k = 0; k < matrixRow; k++) matrix[k][j] = 0;
18
19
20
+}
0 commit comments