We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8e8ce1c commit 2b712d7Copy full SHA for 2b712d7
set-matrix-zeroes/devyejin.py
@@ -0,0 +1,20 @@
1
+from typing import List
2
+class Solution:
3
+ def setZeroes(self, matrix: List[List[int]]) -> None:
4
+ """
5
+ Do not return anything, modify matrix in-place instead.
6
7
+ n, m = len(matrix), len(matrix[0])
8
+ rows, cols = set(), set()
9
+
10
+ for r in range(n):
11
+ for c in range(m):
12
+ if matrix[r][c] == 0:
13
+ rows.add(r)
14
+ cols.add(c)
15
16
17
18
+ if r in rows or c in cols:
19
+ matrix[r][c] = 0
20
0 commit comments