The boat can travel in still water at 20 km/h. In a river with a current of 10 km/h, its speed when sailing downstream is 30 km/h and when sailing upstream it is 10 km/h. The boat has fuel to travel for 4 hours.
The boat sails downstream initially; let the the time after which it has to turn around be T. The distance traveled by the boat sailing downstream for T hours is 30*T. It turns around and has to cover a distance of 30*T in (4 - T) hours at a speed of 10 km/h.
This gives 30*T = 10*(4 - T)
=> 30*T = 40 - 10*T
=> 40*T = 40
=> T = 1
The boat has to turn around after 1 hour to be able to come back to base with the fuel it has.