- Notifications
You must be signed in to change notification settings - Fork 625
/
Copy path73.py
21 lines (20 loc) · 689 Bytes
/
73.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
classSolution(object):
defsetZeroes(self, matrix):
"""
:type matrix: List[List[int]]
:rtype: void Do not return anything, modify matrix in-place instead.
"""
col0=1
forrowinrange(len(matrix)):
ifmatrix[row][0] ==0:
col0=0
forcolinrange(1, len(matrix[0])):
ifmatrix[row][col] ==0:
matrix[row][0] =0
matrix[0][col] =0
forrowinrange(len(matrix)-1, -1, -1):
forcolinrange(len(matrix[0])-1, 0, -1):
ifmatrix[row][0] ==0ormatrix[0][col] ==0:
matrix[row][col] =0
ifcol0==0:
matrix[row][0] =0