Let the distance covered by walking be x km.
Speed while walking = 2 km/h
Time spent on walking = x/2 h
Now, distance covered by runnig = (18 - x) km
Speed while running = 6 km/h
Time spent on running = (18 - x)/6 h
∴x/2 + (18 -x)/6 = 5
⇒ (3x + 18x - x)/6 = 5
⇒ 2x + 18 = 30
⇒ 2x = 12
⇒ x = 6
∴ The distance covered by running = 18 - 6 = 12 km