We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2dc82d8 commit 9d4e348Copy full SHA for 9d4e348
0073M. Set Matrix Zeroes.py
@@ -0,0 +1,20 @@
1
+#Runtime: 112 ms, faster than 99.88% of Python3 online submissions for Set Matrix Zeroes.
2
+#Memory Usage: 15 MB, less than 91.08% of Python3 online submissions for Set Matrix Zeroes.
3
+
4
+class Solution:
5
+ def setZeroes(self, matrix: List[List[int]]) -> None:
6
+ """
7
+ Do not return anything, modify matrix in-place instead.
8
9
+ index_i = set()
10
+ index_j = set()
11
+ for i in range(len(matrix)):
12
+ for j in range(len(matrix[0])):
13
+ if matrix[i][j] == 0:
14
+ index_i.add(i)
15
+ index_j.add(j)
16
17
18
+ if i in index_i or j in index_j:
19
+ matrix[i][j] = 0
20
+ return matrix
0 commit comments