Fast Fourier Transform, Algorithms, Pattern Matching, Convolution, Combination Sum.
combination_sum(p, q): n = max(p) p_coefficients = [0]*(n+1) for i in range(len(p)): p_coefficients[p[i]] += 1 m = max(q) q_coefficients = [0]*(m+1) for i in range(len(q)): q_coefficients[q[i]] += 1 return get_multiplication_coefficients(p_coefficients, q_coefficients) This approach is optimal only