@DanielFischer Consider two sets $D=\{ d_1, d_2, \dots, d_n\}$ and $E=\{ e_1, e_2, \dots, e_m \}$ and consider an other variable $K \geq 0$.
Show that we can answer in time $O((n+m) \lg (n+m))$ the following question:
Is there is a pair of numbers $a,b$ where $a \in D, b \in E$ such that $|a-b| \leq K$?
The algorithm should answer the above question with <<YES>> or <<NO>>.
Describe the algorithm, show its correctness and show that its time complexity is $O((n+m) \lg (n+m))$.