Why do time limit exceeded here!


#1

def setZeroes(self, A):
s = []
t = []
for i in range(len(A)) :
for k in range(len(A[i])) :
if A[i][k] == 0 :
s.append(i)
t.append(k)
for x in s :
for f in range(len(A[x])) :
A[x][f] = 0
for i in range(len(A)) :
for f in t :
A[i][f] = 0
return A


#2

You are using lists to store the index of row and columns where u found zero; please use sets instead of list ; it will result in lower space and time complexity