LEETCODE73Set Matrix Zeroes

xiaoxiao2021-02-28  89

class Solution(object):     def setZeroes(self, matrix):         """         :type matrix: List[List[int]]         :rtype: void Do not return anything, modify matrix in-place instead.         """         height = len(matrix)         if(height ==0): return         width = len(matrix[0])         for i in range(height):             for j in range(width):                 if matrix[i][j] == 0:                     for tmp in range(height):                         if matrix[tmp][j] != 0:                             matrix[tmp][j] = 'a'                     for tmp in range(width):                         if matrix[i][tmp] != 0:                              matrix[i][tmp] = 'a'         for i in range(height):             for j in range(width):                 if matrix[i][j] == 'a':

                    matrix[i][j] = 0

https://leetcode.com/problems/set-matrix-zeroes/#/solutions

转载请注明原文地址: https://www.6miu.com/read-45197.html

最新回复(0)