Fast Fourier Transform, Algorithms, Pattern Matching, Convolution, Combination Sum.
p_coefficients = get_coefficients(p) q_coefficients = get_coefficients(q) n, m = len(p_coefficients), len(q_coefficients) new_coefficients = [0]*(n+m) for i in range(n+m): s = 0 for j in range(n): if 0 <= j < n and 0 <= i-j < m: s += p_coefficients[j]*q_coefficients[i-j] new_coefficients[i] = s h =