Conservation of energy... energy = constant = potential + spring energy = mgh + 0.5*K*x^2, where x is the distance it compresses.
Energy before dropping: mgh (all potential energy, no spring energy)
Energy after dropping: 0.5*kx^2
Energy before = energy after... mgh = 0.5kx^2
Therefore, x = sqrt( (mgh)/(0.5*K) )
There is one important assumption I'm making here though... that x is small compared to h. If this is not true, then that deflection x will cause additional loss in potential energy. If this is an introductory physics course, then I'm sure you can neglect this additional potential energy loss.
If not, x would be found as follows, assuming the top of the uncompressed spring is the datum (the reference line from which you measured h).
Energy before = mgh
Energy after = 0.5*kx^2 + -mgx
So mgh = 0.5*k*x^2 - mgx
Now you solve for x... which is a little messy