The 2.kg mass is heading toward a ramp-there’s no friction. Notice that at the top right there is a relaxed spring. The spring constant is 50 N/m. Calculate the maximum compression of the spring after the mass has risen up the ramp and hit the spring.

the initial KE at bottom of ramp= change in PE of gravity+ change in PE of spring

KEbottom=mgh+1/2 k^x^2
be certain to measure h from the base to the final position at the top for the mass.