from typing import List


class SetMatrixZeros:
    """
    Sets are significantly faster when it comes to determining if an object is present in the set (as in x in s),
    but are slower than lists when it comes to iterating over their contents.
    """

    def setZeroes(self, matrix: List[List[int]]) -> None:
        """
        Do not return anything, modify matrix in-place instead.
        """
        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
