Python Solution (accepted)

> class Solution:
>     # @param A : list of list of integers
>     # @return the same list modified
>     # matrix M x N
>     def setZeroes(self, A):
>         m = len(A)  # number of rows, len of a column
>         n = len(A[0])  # number of columns, len of a row
>         zero_rows_indices = set()
>         zero_cols_indices = set()
>         for i in range(m):
>             for j in range(n):
>                 if A[i][j] == 0:
> 
>                     zero_rows_indices.add(i)
>                     zero_cols_indices.add(j)
> 
>         for i in range(m):
>             if i in zero_rows_indices:
>                 A[i] = [0] * n
>         for j in range(n):
>             if j in zero_cols_indices:
>                 for cell in range(m):
>                     A[cell][j] = 0
> 
>         return A
Click here to start solving coding interview questions