let's take the velocities ( of both balls ) as v0 and v1
Since time taken by both is equal, from the first law of motion, we see Vertical component of both velocities are equal
v1cosθ=v0
2gs=v2−u2
s0=v022g
s1=v12cos2θ2g
s1s0=v12cos2θ2gv022g=v12cos2θv02