The taken by the freely falling stone to reach the ground is given by
\(t=\frac{2h}{g}\)
In both cases, the stone will fall through the same height as it is falling when the railway carriage is stationary. Hence, the stone will reach the ground after 2 seconds.