To solve this problem, you'll have to open it on the computer

Set Matrix Zeroes

Matrix
medium
Score: 10

Given an m x n integer matrix matrix, if an element is 0, set its entire row and column to 0’s, and return the matrix.

You must do it in place.

Input Format

First Parameter - matrix of size m x n

Output Format

Return the matrix.

Example 1:

Input:
     3 3
     1 1 1
     1 0 1
     1 1 1
Output:
     [[1,0,1],[0,0,0],[1,0,1]]
Explanation: 3 3 represents the size of the matrix. All the value which are in row 1 and column 1 is converted to 0.
   

Example 2:

Input:
    3 4
    0 1 2 0
    3 4 5 2
    1 3 1 5
Output:
    [[0,0,0,0],[0,4,5,0],[0,3,1,0]]

Constraints:

  • m == matrix.length
  • n == matrix[0].length
  • 1 <= m, n <= 200
  • -2^31 <= matrix[i][j] <= 2^31 - 1
  • Expected Time Complexity: O(m x n)
  • Expected Space Complexity: O(1)
Submit code to see the your result here