Given,
Masses, m=2kgandM=5kg
Let x be the extension in spring when m=2kg mass leaves contact with the ground.
kx=mg=2g
x=2gk=2×1040=12m
By law of conservation of energy for M=5kg mass
Mgx=12kx2+12Mv2
v=√2MgxM−kx2M
v=√2×10×12−405×(12)2
v=2√2m/s
Hence, Velocity of 5kg is 2√2ms−1