Expected time for winning in biased Gambler's Ruin

The usual approach:

For every $0\leqslant k\leqslant n$, let $u_k=E_k(T:X_T=n)$ and $v_k=P_k(X_T=n)$, then $(u_k)$ and $(v_k)$ are determined by the fact that $u_0=u_n=v_0=0$, $v_n=1$, and, for every $1\leqslant k\leqslant n-1$, $$ u_k=v_k+pu_{k+1}+qu_{k-1},\qquad v_k=pv_{k+1}+qv_{k-1}. $$ The $(v_k)$ system is solved using the usual characteristic equation approach. When $p\ne q$, this yields, for every $0\leqslant k\leqslant n$, $$ v_k=\frac{1-r^k}{1-r^n},\qquad r=\frac{q}p. $$ Plugging this into the $(u_k)$ system and fiddling a little bit with particular solutions such as $u_k=k$, $u_k=r^k$ and $u_k=kr^k$, one can solve for $(u_k)$ and finally deduce the value of $$ E_k(T\mid X_T=n)=\frac{u_k}{v_k}. $$ The case $p=q=\frac12$ is degenerate since $r=1$. Then, $v_k=\frac{k}n$ and, trying particular solutions such as $u_k=k$, $u_k=k^2$ and $u_k=k^3$, one gets $u_k=\frac13nk-\frac1{3n}k^3$, hence $$ E_k(T\mid X_T=n)=\tfrac13(n^2-k^2). $$