1717
1818## Problem Description
1919
20- Given an m x n integer matrix matrix, if an element is 0, set its entire row and column to 0's.
20+ Given an $m \times n$ integer matrix matrix, if an element is 0, set its entire row and column to 0's.
2121
2222You must do it in place.
2323
@@ -28,22 +28,33 @@ You must do it in place.
2828#### Example 1:
2929
3030** Input** :
31+ ```
3132Matrix = [[1,1,1],[1,0,1],[1,1,1]]
33+ ```
3234
33- ** Output** : [[ 1,0,1] ,[ 0,0,0] ,[ 1,0,1]]
35+ ** Output** :
36+ ```
37+ [[1,0,1],[0,0,0],[1,0,1]]
38+ ```
3439
3540#### Example 2:
36- ** Input** : matrix = [[ 0,1,2,0] ,[ 3,4,5,2] ,[ 1,3,1,5]]
41+ ** Input** :
42+ ```
43+ matrix = [[0,1,2,0],[3,4,5,2],[1,3,1,5]]
44+ ```
3745
38- ** Output** : [[ 0,0,0,0] ,[ 0,4,5,0] ,[ 0,3,1,0]]
46+ ** Output** :
47+ ```
48+ [[0,0,0,0],[0,4,5,0],[0,3,1,0]]
49+ ```
3950
4051
4152### Constraints
4253
4354- m == matrix.length
4455- n == matrix[ 0] .length
4556- 1 <= m, n <= 200
46- - -2^31 <= matrix[ i] [ j ] <= 2^31 - 1
57+ - -2< sup >31</ sup > <= matrix[ i] [ j ] <=2< sup >31</ sup > - 1
4758
4859### Approach
4960
@@ -201,4 +212,4 @@ class Solution {
201212
202213 Reason: In this approach, we are also traversing the entire matrix 2 times and each traversal is taking $O(N* M)$ time complexity.
203214
204- - Space Complexity: $O(1)$ as we are not using any extra space.
215+ - Space Complexity: $O(1)$ as we are not using any extra space.
0 commit comments