1
var setZeroes = function (matrix) {2
let rows = new Array(matrix.length).fill(0); //to store the index of rows to be set to 03
let cols = new Array(matrix[0].length).fill(0); //to store the index of columns to be set to 04
for (let i = 0; i < matrix.length; i++) {5
for (let j = 0; j < matrix[i].length; j++) {6
if (matrix[i][j] === 0) {7
//for zero value both row and column will be set to 014
for (let i = 0; i < matrix.length; i++) {15
for (let j = 0; j < matrix[i].length; j++) {16
if (rows[i] === 1 || cols[j] === 1) {17
//if either row or col val is set, poulate it with 0