(matrix, _row, _col)
| 40 | }; |
| 41 | |
| 42 | const setZero = (matrix, _row, _col) => { |
| 43 | const [rows, cols] = [matrix.length, matrix[0].length]; |
| 44 | |
| 45 | for (let row = 0; row < rows; row++) { |
| 46 | /* Time (ROWS) */ |
| 47 | for (let col = 0; col < cols; col++) { |
| 48 | /* Time (COLS) */ |
| 49 | const canSet = _row[row] === 0 || _col[col] === 0; |
| 50 | if (!canSet) continue; |
| 51 | |
| 52 | matrix[row][col] = 0; |
| 53 | } |
| 54 | } |
| 55 | }; |
| 56 | |
| 57 | /** |
| 58 | * Constant Space |