Let x be the speed of the cattle train.
after 14 hrs, the distance it travelled must be 14x since distance =time x rate
then diesel train started travelling at 45 kph.
so, the distance travelled by the diesel train is
(45)4 = 180 km.
if the diesel train run for 4hrs so the cattle train has been travelling for 14 hrs. + 4 hrs. = 18 hrs.
the diesel train caught up which means, they have the same distance already at that point. thus,
180km = 18x