• + 1 comment

    generate_list function in Python would be:

    def generate_list(A, B, n, m, x):
        L = []
    
        for i in xrange(min(n, m - x)):
            for j in xrange((i + x), m):
                L.append(A[i]*B[j])
                
        return L
    

    Do I have to optimize this part as well? Or leave it as it is? I only passed 11 test cases using sort and heapq (I changed append to heappush).