We know that,
Time taken to meet/catch = $\dfrac{\text{Distance separating them}}{\text{Relative Speed}(S_1 \pm S_2)}$
Now,
Relative Speed =$S_1+S_2$, when both the trains are moving in opposite direction.
Relative Speed =$S_1- S_2$, when both the trains are moving in same direction.
Now, assuming,
Distance between both the trains Or Distance between Mumbai to Pune = $x \hspace{0.1cm}km$
& Time taken to meet = $t\hspace{0.1cm} hr.$
$∴ t = \dfrac{x \hspace{0.1cm}km}{(60+40) \hspace{0.1cm}kmph}$
Or, $t = \dfrac{x}{100}hr$ -----------1)
Now, when both the trains meet , One train travelled 20km. more than the other.
As both the train started their journey at same time & train $A's$ speed is greater than the spped of train $B$.
∴ Train $A$ is travelled more.
∴ Distance travelled by $A$ in $t\hspace{0.1cm}hr= 60\times t$
Distance travelled by $B$ in $t\hspace{0.1cm}hr= 40\times t$
Now, given
$\qquad\qquad 60\times t - 40 \times t = 20$
$\qquad\qquad 20\times t = 20$
∴ $t = 1$
∴ Distance between Mumbai and Pune=
$\qquad\qquad t = \dfrac{x}{100}$ ----------- from 1)
Or, $\qquad\qquad x= 100 \times 1 = 100 \hspace{0.1cm}km$
∴ $\color{green}{\text{Distance between Mumbai and Pune is}}$ $\color{gold}{\text{100 km}}$