Solution (source code)

= Solution

Under the risk-neutral measure, write
$$
S_t=S_0e^{X_t},
\qquad
X_t=\left(r-\frac12\sigma^2\right)t+\sigma W_t^Q.
$$
Let $M_T=\max_{t\leq T}X_t$ and $m_T=\min_{t\leq T}X_t$. Then
$$
Y_1=S_0e^{M_T},
\qquad
Y_2=S_0e^{pX_T-m_T}.
$$
The time-reversed increment process
$$
\widetilde X_t=X_T-X_{T-t},
\qquad0\leq t\leq T,
$$
has the same finite-dimensional distributions as $X$, because $X$ has stationary independent increments. Moreover,
$$
\max_{t\leq T}\widetilde X_t=X_T-m_T.
$$
Choosing
$$
\boxed{p=1}
$$
therefore makes $Y_2=S_0e^{X_T-m_T}$ equal in distribution to $Y_1$. Their discounted expectations, and hence their time-zero Black--Scholes prices, are equal. This is <Brownian time reversal for fixed-strike lookback extrema>.