1) Difference in timing of passing the same station is = 2:40 - 2:25 = 0:15 = 1/4 hour
2) Let the two trains meet at a distance of x miles from this station.
3) Time taken by train A to cover this distance of x km = x/40 hour and that by train B = x/48 hour
4) But from step (1), since there is a difference of 1/4 hour between them at the initial station,
==> x/40 = x/48 + 1/4
==> x/40 - x/48 = 1/4
==> 6x - 5x = 60 [Multiplying both sides by 240, which is the LCM of 4, 40 and 48]
So x = 60 miles
Time taken to cover this 60 km by train A = 60/40 = 1.5 hour = 1 hr + 30 min
Hence train B catches the train A at 2:25 + 1:30 = 3:55 am