(a) As the train are moving in the same direction. So the initial relative speed $(v_{1} - v_{2})$ and by applying retardation final relative speed becomes zero
From $v = u - at \Rightarrow 0 = \left( v_{1} - v_{2} \right) - at \Rightarrow t = \frac{v_{1} - v_{2}}{a}$