| 72 | matrix.some((row) => row[0] === 0); /* Time O(ROWS) */ |
| 73 | |
| 74 | var setEdgesToZero = (matrix) => { |
| 75 | const [rows, cols] = [matrix.length, matrix[0].length]; |
| 76 | |
| 77 | for (let row = 0; row < rows; row++) { |
| 78 | /* Time (ROWS) */ |
| 79 | for (let col = 1; col < cols; col++) { |
| 80 | /* Time (COLS) */ |
| 81 | const canSet = matrix[row][col] === 0; |
| 82 | if (!canSet) continue; |
| 83 | |
| 84 | matrix[row][0] = 0; |
| 85 | matrix[0][col] = 0; |
| 86 | } |
| 87 | } |
| 88 | }; |
| 89 | |
| 90 | var setCellsToZero = (matrix, isColZero) => { |
| 91 | const [rows, cols] = [matrix.length, matrix[0].length]; |