The work done on the spring is equal to the elastic potential energy of a spring. We look at Hooke's law, which states that the force needed to stretch a spring is proportional to the displacement of the spring.
F = -kx
W = (integral) Fdx
W = (integral) -kx dx
W = kΔx²/2
20 = k(42 - 30) / 2
k = 10/3