If we assume that the distance travelled after they cross each other is the same, then we can set up a ratio. We know that
`v=d/t` for both trains
and that can be rearranged to
d = v*t
If the distance is the same for both trains
d(A) = d(B)
then the following must also be true
v(A)*t(A) = v(B)*t(B)
Where v and t are the velocity and time of each train (designated by A or B).
We can then rearrange that to find
`(v(A))/(v(B)) = (t(B))/(t(A))`
Since we know that the time for train A is hour and for train B is 2 hours (assuming that because of the way they are written in the problem), then we know that
So Train A is travelling twice as fast as Train B.