hi friend it is a very good Q
i am doing this by work energy theorem
let L be the length
then when it is compressed by a distance x its energy will be
1/2Kx2+mg(L-x)
suppose it has now risen to a height H above its orignal length
then
1/2Kh2+mg(L+H)
equating both of them L will cancel out and
you know to lilift the lower block tention in the spring should be
KH=mg
by replacing these values of H you will get a quadratic in x
and neglect the negative value
plzzz rate me i am new to this
bye