Skip to content

Commit aedf76f

Browse files
committed
feat: Solve set-matrix-zeroes problem
1 parent bba4a94 commit aedf76f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

set-matrix-zeroes/hu6r1s.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution:
2+
def setZeroes(self, matrix: List[List[int]]) -> None:
3+
"""
4+
Do not return anything, modify matrix in-place instead.
5+
"""
6+
zero = []
7+
for i in range(len(matrix)):
8+
for j in range(len(matrix[0])):
9+
if matrix[i][j] == 0:
10+
zero.append((i, j))
11+
12+
for x, y in zero:
13+
for i in range(len(matrix[0])):
14+
matrix[x][i] = 0
15+
for i in range(len(matrix)):
16+
matrix[i][y] = 0

0 commit comments

Comments
 (0)