We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent afedaf9 commit d025143Copy full SHA for d025143
javascript/73-Set-Matrix-Zeroes.js
@@ -0,0 +1,26 @@
1
+/**
2
+ * @param {number[][]} matrix
3
+ * @return {void} Do not return anything, modify matrix in-place instead.
4
+ */
5
+var setZeroes = function(matrix) {
6
+ let row = new Array(matrix.length);
7
+ let col = new Array(matrix[0].length);
8
+
9
+ for (let i = 0; i < row.length; i++) {
10
+ for (let j = 0; j < col.length; j++) {
11
+ if (matrix[i][j] === 0) {
12
+ row[i] = 0;
13
+ col[j] = 0;
14
+ }
15
16
17
18
19
20
+ if (row[i] == 0 || col[j] == 0) {
21
+ matrix[i][j] = 0;
22
23
24
25
26
+};
0 commit comments