0073. 矩阵置零 #12
utterances-bot
started this conversation in
Comments
Replies: 2 comments 1 reply
-
class Solution:
def setZeroes(self, matrix: List[List[int]]) -> None:
m = len(matrix)
n = len(matrix[0])
rows = set()
cols = set()
for i in range(m):
for j in range(n):
if matrix[i][j] == 0:
rows.add(i)
cols.add(j)
for i in range(m):
for j in range(n):
if i in rows or j in cols:
matrix[i][j] = 0 我觉得我这个方法方便一些 |
Beta Was this translation helpful? Give feedback.
1 reply
-
class Solution:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
0073. 矩阵置零 | 算法通关手册
https://algo.itcharge.cn/Solutions/0001-0099/set-matrix-zeroes/
Beta Was this translation helpful? Give feedback.
All reactions