How to find a set of integers that satisfy certain linear conditions Suppose I have a sequence of non-negative integers $J=\{j_1,j_2,\ldots,j_n\}$
and want to find (if possible) a set of integers $I=\{0=i_1<i_2< \cdots < i_m\}$
such that $j_t$ counts the number of pairs $(i_k, i_\ell)$ with $i_\ell>i_k$ and $i_\ell-i_k=t$.
E.g., if $J=\{3,2,2,2,1\}$, then we can take $I=\{0,1, 2, 4, 5\}$.
Of course, $\sum_{k=1}^{n} j_{k}=m(m-1)/2$, $i_m=n$, $j_n=1$.
My question is what is known about this problem (citations to the literature,...) and whether there exists an efficient algorithm
for finding such $I$ for a given $J$, or determining that no such $I$ exists for a given $J$.
 A: In a slightly different notation, your question reads as follows: 
Given positive integers $m$ and $n$, and a function $r\colon[-n,n]\to{\mathbb Z}_{\ge 0}$ with $r(0)=m$, $r(n)=1$,  $r(-n)+\dotsb+r(n)=m^2$, and $r(-d)=r(d)$ for each $d\in[1,n]$, does there exist an $m$-element set $A\subseteq[0,n]$ such that every integer $d\in[-n,n]$ has exactly $r(d)$ representations as a difference of two elements of $A$?
There are numerous necessary conditions one can give; for instance, letting $D:=\mathrm{supp}\,r$,


*

*$m\le n+1$ and $r(d)\le m-1$ for each $d\in[1,n]$;

*$|D|\ge m+\min\{2m-3,n\}$ (Freiman's $(3n-3)$-theorem for the difference set);

*$m(2m-1)\le\sum_{d=-n}^n r^2(d)\le\frac13(2m^2+1)m$ (the additive energy of $A$ is somewhere between those of a Sidon set and of an arithmetic progression of size $m$).


For a slightly more elaborate condition, observe that 
  $$ \Bigg| \sum_{a\in A} e^{2\pi iat} \Bigg|^2 = \sum_{d=-n}^n r(d) e^{2\pi idt} = m + 2\sum_{d=1}^n r(d) \cos(2\pi dt) $$ 
for any real $t\in[0,1]$; as a result,
  $$ \sum_{d=1}^n r(d)\cos(2\pi dt)\ge -m/2,\quad t\in[0,1]. $$
This seems a rather strong condition to me, but it certainly is not sufficient: for any function $f\colon[0,n]\to\mathbb Z_{\ge 0}$, the "skew convolution" $r(d):=\sum_{x}f(x)f(x+d)$ satisfies this condition.
For the algorithmic aspect, you can just check all $m$-element subsets $A\subseteq D$ with $\min A=0$ and $\max A=n$. To make it efficient, use branch-and-cut, starting from $A_0=\{0,n\}$ and at each step trying to expand the set already constructed by adding to it the elements $2,3,\dotsc,n-1$. While adding elements, keep track of the number of representations of each $d\in[1,n]$: if this number ever exceeds $r(d)$, cut this branch and proceed, trying to add the next element.
