i think u have to use
d2x/dt2 +(2k*x)/m2m3 =0
Two masses m2 and m3 are connected by a spring of spring constant k and are placed on a frictionless horizontal surface. Initially the spring is stretched through a distance x when the system is released from rest. Find the distance moved by the two masses before coming to rest. Ans: 2m3x/m2+m3, 2m2 x/m2+m3.
let the distance moved be x2 and x3
centre of mass remains at same position
so m2x2=m3x3
x2+x3=2x (as they come to rest after compression in the spring is x)
solve for x2 and x3