As PhanthomJay said, W = (1/2)kr2 is not Hooke's law. You don't want to use W = (1/2)kr2 when calculating the spring constant. (Although you will use it later when calculating the spring's potential energy.)
If you are puzzled as to why this conservation of energy approach does not work for calculating the spring constant k, I might be of help. Using the equation
mgh = (1/2)kh2
Implies the following: Initially, the weight is put on the relaxed spring, then released such that weight falls on its own accord. Eventually, the weight's velocity will momentarily drop back to zero when it falls a distance h below its initial position. At this point in time the initial energy of mgh has been transferred to the potential energy of the spring, (1/2)kh2.
But it won't stop there! The mass will then shoot back up to its initial position and oscillate back and forth like that until frictional forces slowly dampen the oscillation.
So that h that I describe above is not the h that you are looking for.
In this problem, instead of letting the mass fall on its own accord, the mass is gently lowered until it reaches a distance of 20 cm, at which point the system stays in a state of equilibrium (no oscillations). That's where you want to use Hooke's law to find the spring constant. Hooke's law describes force; not potential energy (at least not directly).