Let x represent the speed of the first train. The second train travels 50mph faster than the first. It means that the speed of the second train is (x + 50) mph.
Distance = speed × time
If the second train overtakes the first at 7:00 PM, it means that both trains covered the same distance by 7:00 PM. The first train left Miami at 3:00PM. Time spent by the first train is 7 - 3 = 4 hours
Distance covered by the first train in 4 hours is 4x
The second train left at 5:00 PM. Time spent by the second train is 7 - 5 = 2 hours
Distance covered by the second train in 2 hours is 2(x + 50)