
So we can divide the time period in two parts. first $T_{1}$ and second $T_{2}$
$T_{1}$ is half of the time period of a full SHM i.e. $T_{1}=\pi \sqrt{\frac{m}{k}}$
$E=\frac{1}{2} m v_{\max }^{2}$
$\Rightarrow v_{\max }=\sqrt{\frac{2 E}{m}}$
and $T_{2}$ is the time during which the particle remains in air when it is thrown upwards with velocity $v_{\max }=\sqrt{\frac{2 E}{m}}$
$0=\sqrt{\frac{2 E}{m}} t-\frac{1}{2} g t^{2} \quad$ since $s=u t-\frac{1}{2} g t^{2}$
$\Rightarrow T_{2}=2 \sqrt{2 E / m g^{2}}$
So total time time period $T=\pi \sqrt{\frac{m}{k}}+2 \sqrt{\frac{2 E}{m g^{2}}}$

