Fast Fourier Transform, Algorithms, Pattern Matching, Convolution, Combination Sum.
requirement becomes double. Let’s look at another problem. Combination Sums Given 2 integer arrays P and Q, consisting of positive integers, for each unique sum p+q where p is from P and q is from Q, find their frequencies. For e.g. P=[1,2,3,4], Q=[3,1,5,4], then all possible p+q’s are : 1+3=4