Distribution of stopping time for biased random walk using martingales.

We may apply the optional stopping theorem to the first problem, because $|Z_{n \land T}| \leq 1 < \infty$, and get: $$1 = E(Z_0) = E(Z_T) = (q/p)^{-a} P(S_T = -a) + (q/p)^{b} P(S_T = b)$$

Using the fact that $P(S_T = b) = 1 - P(S_T = -a)$, we may rearrange to get: $$ \begin{align*} P(S_T = b) &= \frac{1- (q/p)^{-a}}{(q/p)^b - (q/p)^{-a}} \\ P(S_T = -a) &= \frac{(q/p)^b - 1}{(q/p)^b - (q/p)^{-a}} \end{align*}$$

To see that the optional stopping theorem holds for $Y_n$, note that it has bounded increments and that you may stochastically bound $Y_n$ by a geometric random variable (e.g. $T \leq (a+b)G$ where $G \sim Geo(q^{a+b})$) to get that $E(T) < \infty$.

You may also apply the optional stopping theorem to $Y_n$ to get: $$0 = E(Y_0) = E(Y_T) = E(S_T) - E(T)E(X_1)$$

So that $E(T) = E(S_T) / E(X_1)$, whose exact value you can now calculate from a previous question.