Hi , I tried something like : def find_max_one(A): rows=len(A) cols=len(A[0]) sum=[] for i in range(0,rows): max_one=-1 for j in range(0,cols): max_one=max_one+A[i][j] sum.append(max_one) Final=sum.index(max(sum)) print("Index of max number of ones is ",Final) i am not trying to count the number of ones rather summing up all ones and get maximum sum of that row, next i am storing that sum in a list then calling the max and index function on it
@LazyProgrammerOfficial Жыл бұрын
Thanks for your contribution! Note that the sum function is still O(N). ;)