MCPcopy Create free account
hub / github.com/neetcode-gh/leetcode / setZero

Function setZero

javascript/0073-set-matrix-zeroes.js:42–55  ·  view source on GitHub ↗
(matrix, _row, _col)

Source from the content-addressed store, hash-verified

40};
41
42const 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

Callers 1

setZeroesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected