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.
Note:
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.
Output Format:
Return 'N' rows consisting of 'M' integers representing the matrix.
Note:
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.
Follow Up:
Can you solve it with the space complexity of O(1)?
Time limit: 1 sec
2 3
2 4 3
1 0 0
2 0 0
0 0 0
1 1
5
5
1. Think about how to identify the rows and columns containing a '0' element and then modify the matrix accordingly to make all elements in those rows and columns equal to 0.
2. You can use the first row and first column of the matrix itself as indicators to mark whether a particular row or column needs to be zeroed
We can use two vectors of datatype bool of size ‘N’ and ‘M’, let say ‘ROW’ and 'COL' respectively.
The steps are as follows:
O(N*M), Where ‘N’ is the number of rows and ‘M’ is the number of columns.
Since we are traversing the whole matrix of size N * M. Thus the time complexity will be O(N * M).
O(N + M), Where ‘N’ is the number of rows and ‘M’ is the number of columns.
Since we are creating two vectors of the size ‘N’ and ‘M’ for the row and column respectively. Thus the space complexity will be O(N + M).