Im trying to figure out the time complexity of the following code. lst_of_lsts contains m lists whose lengths are at most n.
This is what I think: all runs in O(m*n), minimum = O(m*n), remove = O(m*n).
Overall O(m*n)*O(m*n) = O(m^2*n^2)
Am I right?
def multi_merge_v1(lst_of_lsts):
all = [e for lst in lst_of_lsts for e in lst]
merged = []
while all != []:
minimum = min(all)
merged += [minimum]
all.remove(minimum)
return merged