Two bodies A and B of masses 2m and 3m respectively are placed on a smooth floor. They are connected by a spring. A third body C of mass 2m moving with velocity v0 hits A along AB elastically as shown in figure. At a certain instant of time when x in the spring is maximum, the velocity v of both the masses is same. Find x and v.

Given that initially, A is at rest and C is moving with velocity v0.
The masses of A and C are same, therefore when C hits A elastically, it itself gets stopped and A starts moving with velocity v0. There is a transfer of velocity in an elastic collision.
Just after collision, A moves with velocity v0.
B is at rest and spring is normal.
The momentum of system (bodies A, B and spring) is 2mv0.
Energy, E = , which is in the form of kinetic energy of A.
No external force is acting on the system, therefore, the momentum of the system remains conserved.
Using conservation of momentum at the instant of maximum compression,
Now to find x, again using the principle of conservation of momentum at the instant of compression, we have
i.e.,