Required time = \(\frac{\text{Total distance}}{\text{Relative speed}}\) = \(\frac{\text{Sum of the lengths of the two trains}}{\text{Sum of speeds}}\)
= \(\frac{(140+160)\times18}{(60+40)\times5}\) seconds = \(\frac{300\times18}{100\times5}\) = 10.8 seconds.