Let distance be d
Speed (1) = 20km/h
Time taken = distance / speed
= d/20
Speed (2) = 30km/h
Time = Distance/time
= d/30
Average speed = total distance /total time
=( d+d) /{(d/20)+(d/30)}
= 2d / (d/12)
=24d/ d
= 24
So, the average speed of the car was 24km/h