when a mass m is Attached to the spring of force constant k, then the spring stretches by l. if the mass oscillates with amplitude l, the max potential energy in the spring is: a.mgl/2 b. mgl
Just apply work energy theorem to this question and you will get the answer easily.
First equate Work done by gravitational force + Work Done by Spring force = Change in Kinetic energy
Now you find the x. Then according by the formula of potential energy you can easily find the maximum potential energy and hence your answer will be matched.