Solution (source code)

= Solution

Take horizontal motion towards the second projectile as positive. In <projectile motion>, both bodies have the same downward <gravitational acceleration>, so it cancels from their relative motion. Their coordinates are
$$
x_1=v_1t,\quad z_1=h-\frac12gt^2,\qquad x_2=v_2t\cos\theta,\quad z_2=v_2t\sin\theta-\frac12gt^2.
$$
For a collision at $t>0$, equality of the horizontal coordinates requires $v_2\cos\theta=v_1$. Equality of the heights then requires $v_2t\sin\theta=h$. Hence
$$
\boxed{\theta=\arccos\frac{v_1}{v_2},\qquad t=\frac{h}{\sqrt{v_2^2-v_1^2}}.}
$$
The upward solution requires $v_2>v_1$. A collision strictly above the ground further requires $t<\sqrt{2h/g}$, or $v_2^2-v_1^2>gh/2$. The horizontal target distance does not independently affect the interception geometry. If the first shot is also required to hit that ground target, its parameters satisfy $l=v_1\sqrt{2h/g}$.