


You are given a matrix 'MATRIX' of dimension 'N' x 'M'. Your task is to make all the elements of row 'i' and column 'j' equal to 0 if any element in the ith row or jth column of the matrix is 0.
1) The number of rows should be at least 1.
2) The number of columns should be at least 1.
3) For example, refer to the below matrix illustration:

The first line contains two space-separated integers, 'N' and 'M', as described in the problem statement.
The next 'N' lines contain 'M' integers separated by spaces describing rows of the matrix.
Return 'N' rows consisting of 'M' integers representing the matrix.
You don't need to print anything, it has already been taken care of. Just implement the given function.
1 <= N <= 100
1 <= M <= 100
-10^9 <= MATRIX[i][j] <= 10^9
Where 'MATRIX[i][j]' denotes the matrix element.
Can you solve it with the space complexity of O(1)?
Time limit: 1 sec
We can use two vectors of datatype bool of size ‘N’ and ‘M’, let say ‘ROW’ and 'COL' respectively.
The steps are as follows:
We can use the 1st row and 1st column which means the 1st cell of every row and column as an indicator. ‘MATRIX[0][0]’ will tell us whether we have to set the entire 1st row to be zero or not, and a bool variable ‘ISCOLZERO’ will tell us the same for the entire 1st column.
The steps are as follows: