problem of maximum in physics Aa elastic ball with a mass $m_1$ is moving at the speed of $v$ and strikes a first elastic ball at rest.
The second ball, with a mass $m_2$ acquires a speed $v_2$ and strikes a third elastic ball at rest, with a mass $m_3$, giving it a speed $v_3$.
If the masses of the first and the third balls are fixed, find what mass should be the second ball in order to have the highest velocity for the third ball.
I've tried with the conservation of the momentum and kinetic energy.
$m_1* (v_{m1})^i=m_1* (v_{m1})^f+m_2* (v_{m2})^f+m_3* (v_{m3})^f$
$(v_{m1})^i=(v_{m1})^f+(v_{m2})^f+(v_{m3})^f$
but I'm afraid I'm lost

In the first collision, the initial velocity of the first and second ball are $v_1$ and $0$ respectively, and the final ones are $v_1'$ and $v_2$. The conservation of momentum and kinetic energy gives:
$$\left.\begin{array}{c}
m_1v_1+m_2\cdot 0 = m_1v_1' + m_2v_2\\
\frac12 m_1v_1^2+\frac12 m_2\cdot 0^2 = \frac12m_1v_1'^2 + \frac12m_2v_2^2 
  \end{array}\right\} \implies v_1' = \frac{m_1-m_2}{m_1+m_2}v_1,\quad v_2 = \frac{2m_1}{m_1+m_2}v_1.
$$
In the second collision, the initial velocity of the second and third ball are $v_2$ and $0$ respectively, and the final ones are $v_2'$ and $v_3$. The conservation of momentum and kinetic energy gives:
$$\left.\begin{array}{c}
m_2v_2+m_3\cdot 0 = m_2v_2' + m_3v_3\\
\frac12 m_2v_2^2+\frac12 m_3\cdot 0^2 = \frac12 m_2v_2'^2 + \frac12m_3v_3^2 
  \end{array}\right\} \implies v_2' = \frac{m_2-m_3}{m_2+m_3}v_2,\quad v_3 = \frac{2m_2}{m_2+m_3}v_2.
$$
$v_3$ in terms of constants $m_1, m_3, v_1$ expressed as a function of $m_2$ is
$$v_3(m_2) = \frac{4m_1m_2}{(m_1+m_2)(m_2+m_3)}v_1.$$
Calculating $v_3'(m_2) = 0$ yields that $m_2 = \sqrt{m_1m_3}$.
