Python soln using set


#1
def setZeroes(self, A):
    r=len(A)
    c=len(A[0])
    zrow=set()
    zcol=set()
    for i in range(r):
        for j in range(c):
            if A[i][j]==0:
                zrow.add(i)
                zcol.add(j)
    for i in range(r):
        for j in range(c):
            if i in zrow or j in zcol:
                A[i][j]=0
    return A