var setZeroes = function (matrix) { let arr = []; let m = matrix[0].length; let n = matrix.length; let x = []; let y = []; for (let i = 0; i < n; i++) { for (let j = 0; j < m; j++) { if (matrix[i][j] == 0) { if (!x.includes(j)) { x.push(j); } if (!y.includes(i)) { y.push(i); } } } } for (let i = 0; i < n; i++) { for (let j = 0; j < m; j++) { if (x.includes(j)) { matrix[i][j] = 0; } if (y.includes(i)) { matrix[i][j] = 0; } } } return matrix; };