Let the hours driven at a speed of 20 km/h be x hr.
So hours driven at the speed of 10 km/h = (3 - x) hr
Distance=Speed×Time
Distance travelled at a speed of 20 km/ hr is 20x km.
Distance travelled at a speed of 10 km/ hr is 10(3-x) km.
Total distance covered is 50 km.
So,
20x+10(3−x)=50 20x+30−10x=50 10x=20 x=2 hr