Gambler's ruin
Consider a random walk where at each step $k$, $$ \prob(Y_k = +1) = p, \quad \prob(Y_k = -1) = 1-p \equiv q. $$ The gambler will walk away either when $X_n = a$ or 0.
The key is to see that if we condition on the first step, say $Y_1=1$, then $(X_{n+1})_{n\geq 0}$ is again a simple random walk with the same step distribution.
Denote $\prob_x$ and $\expect_x$ for probability and expectation regarding initial value $x$, and $$ T = \min\sb{n\geq 0}{X_n=0\text{ or } a}. $$