Set Matrix Zeroes

class Solution:
    # @param matrix, a list of lists of integers
    # RETURN NOTHING, MODIFY matrix IN PLACE.
    def setZeroes(self, matrix):
        di=[]
        dj=[]
        n=len(matrix)
        if n==0 :return 
        m=len(matrix[0])
        for i in range(n):
            for j in range(m):
                if matrix[i][j]==0:
                    di.append(i)
                    dj.append(j)
        for k in di:
            for i in range(m):
                matrix[k][i]=0
        for k in dj :
            for i in range(n):
                for j in range(m):
                    if j==k:
                        matrix[i][j]=0

没什么好说的

posted @ 2014-08-29 15:16  clq.lib  阅读(111)  评论(0编辑  收藏  举报