Answer
Acceleration is $$a_B=-2.5ms^{-2}$$
Work Step by Step
Step-1: At time $t=4.0s$, car $A $ has traveled $x=7\times 4 = 28m$ ($4m$ is the unit of the displacement axis, as shown in the graph).
Step-2: It is given that car $B$ has an initial velocity, $u=12 ms^{-1}$ and a negative acceleration of $a_B$. Now, we need to find $a_B$ such that both the cars are side-by-side at time $t=4.0s$, meaning that the displacement of car $A$ = displacement of car $B$ at $t=4.0s$. This displacement = $28m$ for car A (from Step-1). From the relation,
$$s=ut+\frac{1}{2} at^2$$ where $s$ is the displacement of the car, at time $t$, which is moving with initial velocity $u$ and constant acceleration $a$.
$$28=12\times 4+\frac{1}{2}a_B\times4^2$$
$$\implies a_B = -2.5ms^{-2}$$