
Answer:
K = mg h
Explanation:
We will solve this exercise through energy conservation
Initial. Highest point
    Em₀ = U = m g (h + x)
Final. When the spring hits
    [tex]Em_{f}[/tex] = K + U = K + mg x
    Em₀ = [tex]Em_{f}[/tex]
    m g (h + x) = K + mgx
    mg h (h + x) –mgx = K
    K = mg h
We can also solve it with the points
Initial. Spring contact point
    Em₀ = K + U = K + m g x
Final. Maximum compression
    [tex]Em_{f}[/tex] = [tex]K_{e}[/tex] = ½ k x²
    Emo =[tex]Em_{f}[/tex]
    K + mg x = ½ k x²
    K = ½ k x² - mg x