(b) The amplitude of oscillations will be the maximum compression is the spring. At the time of maximum compression velocities of both the blocks are equal say $v$, then using law of conservation of momentum,
$m_{1}v_{0} = \left( m_{1} + m_{2} \right)v$
or $1 \times 12 = (1 + 2)v\ \ or\ \ v = 4\ cms^{- 1}$
Using law of conservation of energy, we have
$\frac{1}{2}m_{1}v_{0}^{2} = \frac{1}{2}kx^{2} + \frac{1}{2}\left( m_{1} + m_{2} \right)v^{2}$
Putting the value and solving we get $x = 2$ cm