Fast Fourier Transform, Algorithms, Pattern Matching, Convolution, Combination Sum.
1+1=2 1+5=6 1+4=5 2+3=5 2+1=3 2+5=7 2+4=6 3+3=6 3+1=4 3+5=8 3+4=7 4+3=7 4+1=5 4+5=9 4+4=8 The frequencies are: 2:1 3:1 4:2 5:3 6:3 7:3 8:2 9:1 Straightforward approach is to sum each element of P with each element of Q, and use a hash table to count the frequencies. Time complexity is O(N²) where N