The space between the tops of the two walls can be thought of as an inclined plane. Then the problem is to find the minimum speed to cover distance $L$ on a plane inclined at $\theta$ to the horizontal where $L\sin\theta=h_2-h_1$. (I assume we are launching up the plane. However, the projectile can follow the same total trajectory in reverse with the same launch velocity from the ground, because the trajectory is symmetrical. So we can always arrange to launch up the inclined plane.)
The maximum range on an inclined plane is given by $$R=\frac{u^2}{g(1+\sin\theta)}$$ Using $R=L$ we get a minimum launch speed of $u$ given by $$u^2=g(L+h_2-h_1)$$ To obtain speed $u$ at height $h_1$ above the ground the stone must be launched with speed $v$ given by $$v^2=u^2+2gh_1$$ Therefore $$v^2=g(L+h_1+h_2)$$