M1v1savva's blog

By M1v1savva, history, 4 years ago, In English

The problem is the following:

We have array $$$a$$$ of $$$n$$$ integers and for each integer $$$k$$$ from $$$1$$$ to $$$n$$$ we want to calculate the number of pairs $$$(i, j)$$$ such that $$$a_i + a_j = k$$$.

I wonder if it can be solved in less than $$$\mathcal{O}(n^2)$$$

UPD: turns out it is a classical FFT problem

  • Vote: I like it
  • -17
  • Vote: I do not like it

»
4 years ago, # |
Rev. 13   Vote: I like it -16 Vote: I do not like it
I have this approach but it may be wrong