Answer:
 h ’= k  (h +L/2)²/ (2 M g )
Explanation:
For this exercise, one of the best methods to solve it is with energy conservation.
Starting point. Lower, spring with maximum compression
       Em₀ = Ke = ½ k x²
Final point. Higher after bounce
       = U = M g h ’
       Em₀ = Em_{f}
       ½ k x² = M g h’
      Â
the compressed distance is
     x = h+ L / 2
where h is the distance that compresses the spring by the height where it comes from and L/2 the additional compression
    h ’= ½ k x² / M g
we calculate
    h ’= k  (h +L/2)²/ (2 M g )
    h' = (k/2Mg) h2 (1 + L/2h)2