Fast Fourier Transform, Algorithms, Pattern Matching, Convolution, Combination Sum.
the count of S-p in the hash table, add the count to frequency of sum S. Time complexity of this approach is O(N*M). Another approach is to consider 2 polynomials P(x) and Q(x) as follows: where a_i = count of element i in array P and b_i = count of element i in array Q. When we multiple P(x) and