Solution
= Solution
Until the walk first reaches $B$, it is the <simple random walk> on a path of length $n$ with reflection at the endpoint $A$. If $h_i$ is the <expected hitting time> of $B$ from the vertex at distance $i$ from $A$, then
$$
h_n=0,
\qquad h_0=1+h_1,
\qquad h_i=1+\frac12(h_{i-1}+h_{i+1})\quad(1\leq i<n).
$$
Solving this second-difference equation gives $h_i=n^2-i^2$. Therefore
$$
\boxed{\mathbb E_A[T_B]=n^2}.
$$