Problem
Given an m x n integer matrix, whenever a cell is 0, set its entire row and its entire column to `0`. Do it in place. Only zeros that were in the original matrix cause this; zeros you write do not spread further. As a follow-up, use O(1) extra space.
Example 1
[[1, 1, 1], [[1, 0, 1],
Example 2
- Input
- [1, 0, 1],
- Output
- [0, 0, 0],
Example 3
[1, 1, 1]] [1, 0, 1]]
Example 4
[[0, 1, 2, 0], [[0, 0, 0, 0],
Example 5
- Input
- [3, 4, 5, 2],
- Output
- [0, 4, 5, 0],
Example 6
[1, 3, 1, 5]] [0, 3, 1, 0]]
The function returns nothing; the tests inspect matrix after the call.
Constraints
m == matrix.lengthn == matrix[0].length1 <= m, n <= 200-2^31 <= matrix[i][j] <= 2^31 - 1