Solution (source code)

= Solution

For a chosen unit vector $|\psi\rangle$, the two possible outputs have inner product
$$
\langle\psi|U_2^\dagger U_1|\psi\rangle.
$$
Part (a) says they can be perfectly distinguished exactly when this inner product is zero. Such an input exists exactly when
$$
\boxed{0\in\{\langle\psi|U_2^\dagger U_1|\psi\rangle:\|\psi\|=1\}
=N(U_2^\dagger U_1).}
$$