17
17
18
18
## Problem Description
19
19
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.
21
21
22
22
You must do it in place.
23
23
@@ -28,22 +28,33 @@ You must do it in place.
28
28
#### Example 1:
29
29
30
30
** Input** :
31
+ ```
31
32
Matrix = [[1,1,1],[1,0,1],[1,1,1]]
33
+ ```
32
34
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
+ ```
34
39
35
40
#### 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
+ ```
37
45
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
+ ```
39
50
40
51
41
52
### Constraints
42
53
43
54
- m == matrix.length
44
55
- n == matrix[ 0] .length
45
56
- 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
47
58
48
59
### Approach
49
60
@@ -201,4 +212,4 @@ class Solution {
201
212
202
213
Reason: In this approach, we are also traversing the entire matrix 2 times and each traversal is taking $O(N* M)$ time complexity.
203
214
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