Given a matrix of r x c elements, where r is the number of rows and c is the number of columns. It contains 0's and 1's as values. If any element is 0 in the matrix, you have to set its entire row and column to 0.

Problem Note

  • Solve this problem in-place.

Example 1

Input:
     [ [0, 1],        
       [1, 1] ]         
Output:
     [ [0, 0],
       [0, 1] ] 
Explanation: In the above input matrix, the element in the '1st row and 1st column' is 0. So in the resultant matrix, all the elements of the 1st row and 1st column are set to 0.

Example 2

Input:
     [ [1, 1, 1],
       [1, 0, 1], 
       [1, 1, 1] ]
Output:
     [ [1, 0, 1],
       [0, 0, 0],
       [1, 0, 1] ]
Explanation: In the above input matrix, the element in the '2nd row and 2nd column' is 0. So in the resultant matrix, all the elements of the 2nd row and 2nd column are set to 0.