Expected time for winning in biased Gambler's Ruin
Consider the random walk $X_0, X_1, X_2, \ldots$ on state space $S=\{0,1,\ldots,n\}$ with absorbing states $A=\{0,n\}$, and with $P(i,i+1)=p$ and $P(i,i-1)=q$ for all $i \in S \setminus A$, where $p+q=1$ and $p,q>0$.
Let $T$ denote the number of steps until the walk is absorbed in either $0$ or $n$.
Let $\mathbb{E}_k(\cdot) := \mathbb\{\cdot | X_0 = k\}$ denote the expectation conditioned on starting in state $k \in S \setminus A$.
How to compute $\mathbb{E}_k(T|X_T = n)$?
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). $$