#### Consider that A takes t1 second, then according to the
given problem, B will take (t1+t)
seconds. Further let v1 be the velocity of B at
finishing point, then velocity of A will be (v1+v). Writing equations of motion for A and B

v1+v=a1t1 ....(i)

v1=a2(t2+t) ....(ii)

From equations (i) and (ii), we get

v=(a1−a2)t1−a2t .....(iii)

Total distance travelled by both the cars is equal

SA=SB

⇒12a1t21=12a2(t1+t)2⇒t1=√a2t√a1−√a2

Substituting this value of t1 in equation (iii), we get

v=(√a1a2)t