(matrix, isColZero)
| 88 | }; |
| 89 | |
| 90 | var setCellsToZero = (matrix, isColZero) => { |
| 91 | const [rows, cols] = [matrix.length, matrix[0].length]; |
| 92 | |
| 93 | for (let row = rows - 1; 0 <= row; row--) { |
| 94 | /* Time (ROWS) */ |
| 95 | for (let col = cols - 1; 1 <= col; col--) { |
| 96 | /* Time (COLS) */ |
| 97 | if (!isZero(matrix, row, col)) continue; |
| 98 | |
| 99 | matrix[row][col] = 0; |
| 100 | } |
| 101 | |
| 102 | if (isColZero) matrix[row][0] = 0; |
| 103 | } |
| 104 | }; |
| 105 | |
| 106 | var isZero = (matrix, row, col) => { |
| 107 | const [rowLeftEdge, colTopEdge] = [matrix[row][0], matrix[0][col]]; |