Let distance covered, AB = x.
Therefore total distance traveled = 2x.
Let t1 be the time taken to move from A to B and speed v1=30 kmph.
t2 be the time taken to move from B to A and speed v2=20 kmph.
We know time=distancespeed
t1=x30 and t2=x20
Total time =t1+t2=5x60.
Average speed for entire journey
=Total distanceTotal time=2x5x60=24 kmph