Nice problem
Let $V_A$ be the speed of your car A & $V_B$ be the speed of the car B behind you.
Since car B is to overtake you hence its speed is taken greater than that of your car i.e. $V_B>V_A$
Now, the relative velocity of car B approaching your car is given as $$V_B-V_A$$
Now, at any moment, let $d$ be the distance between your car A & car B behind you then the time taken by car B to overtake you is $$=\frac{\text{distance between car A & B}}{\text{relative velocity of car B w.r.t. car A}}$$ $$=\frac{d}{V_B-V_A}$$