Solution (source code)

= Solution

Since $Y_n\to+\infty$ <almost surely>, only finitely many early values can attain the global <minimum>; it is a finite <integer>. Also $W\leq Y_0=0$. For every <nonnegative integer> $m$, the unit-step property and translation invariance of the increments give
$$
\mathbb P(-W\geq m)
=\mathbb P_0(\text{ever visit }-m)
=\mathbb P_m(\text{ever visit }0)=\beta^m,
\qquad\beta=\frac{1-p}{p}.
$$
Subtracting consecutive tails yields the <probability mass function>
$$
\boxed{\mathbb P(-W=m)=(1-\beta)\beta^m,\qquad m=0,1,\ldots.}
$$
Thus $-W$ has the <geometric distribution> counting failures before the first success, with success parameter
$$
\boxed{1-\beta=\frac{2p-1}{p}.}
$$
This support convention is essential: the <minimum of an upward-biased random walk> can equal its starting position, so $-W=0$ has positive <probability>.