<jupyter_start><jupyter_text>给定一个 m x n 矩阵，如果元素为0，则将其整个行和列设置为0。就地进行设置。        例1：        Input:         [          [1,1,1],          [1,0,1],          [1,1,1]        ]        Output:         [          [1,0,1],          [0,0,0],          [1,0,1]        ]        例2：        Input:         [          [0,1,2,0],          [3,4,5,2],          [1,3,1,5]        ]        Output:         [          [0,0,0,0],          [0,4,5,0],          [0,3,1,0]        ]          后续行动：     1、使用O（mn）空间的直接解决方案可能不是一个好主意。     2、一个简单的改进使用O（m+n）空间，但仍然不是最佳解决方案。     3、您可以设计一个恒定的空间解决方案吗？<jupyter_code>class Solution:
    def setZeroes(self, mat) -> None:
        """
        Do not return anything, modify matrix in-place instead.
        """
        rows = len(mat)
        cols = len(mat[0])
        
        zero_cord = []
        for row in range(rows):
            for col in range(cols):
                val = mat[row][col]
                if val == 0:
                    zero_cord.append([])
                    zero_cord[-1] = [row, col]
        
        zero_rows = [x[0] for x in zero_cord]
        zero_cols = [x[1] for x in zero_cord]
        for row in range(rows):
            for col in range(cols):
                if row in zero_rows:
                    mat[row][col] = 0
                if col in zero_cols:
                    mat[row][col] = 0
        return
mat_ = [
          [0,1,2,0],
          [3,4,5,2],
          [1,3,1,5]
        ]
solution = Solution()
solution.setZeroes(mat_)<jupyter_output>[[0, 0, 0, 0], [0, 4, 5, 0], [0, 3, 1, 0]]
{'fraction_non_alphanumeric': 0.147498375568551, 'fraction_numerical': 0.05198180636777128, 'mean_word_length': 1.2254335260115607, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '535316', 'license': 'Apache-2.0', 'n_tokens_mistral': 624, 'n_tokens_neox': 612, 'n_words': 113, 'path': 'Array/0807/73. Set Matrix Zeroes.ipynb', 'repo_name': 'YuHe0108/Leetcode', 'size': '1539'}