Tech Mahindra Interview Question

problems on trains and streams...comprehension