Untitled

mail@pastecode.io avatar
unknown
python
a month ago
449 B
3
Indexable
Never
class Solution:
    def setZeroes(self, matrix: List[List[int]]) -> None:

        m,n = len(matrix), len(matrix[0])
        row, col = set(), set()
        
        for i in range(m):
            for j in range(n):
                if matrix[i][j]==0:
                    row.add(i)
                    col.add(j)
        for i in range(m):
            for j in range(n):
                if i in row or j in col:
                    matrix[i][j] = 0
Leave a Comment