The gravitational force acting on the mass can be given as,
[tex]F=mg[/tex]The spring constant of the spring can be given as,
[tex]k=\frac{F}{d}[/tex]Substitute the known expression,
[tex]k=\frac{mg}{d}[/tex]Substitute the known values,
[tex]\begin{gathered} k=\frac{(0.368kg)(9.8m/s^2)}{(12.3\text{ cm)(}\frac{1\text{ m}}{100\text{ cm}})}(\frac{1\text{ N}}{1kgm/s^2}) \\ \approx29.3\text{ N/m} \end{gathered}[/tex]The work done on the spring can be given as,
[tex]W=\frac{1}{2}kx^2[/tex]Substitute the known values,
[tex]\begin{gathered} 0.399J=\frac{1}{2}(29.3N/m)x^2 \\ x^2=\frac{2(0.399\text{ J)}}{29.3\text{ N/m}}(\frac{1\text{ Nm}}{1\text{ J}}) \\ x=\sqrt[]{0.0272m^2} \\ \approx0.165\text{ m} \end{gathered}[/tex]Thus, the distance of spring stretched is 0.165 m.