If b = 0, then the result immediately follows. If $b \neq 0$, as $a$ is not coprime with $n$, $ab$ is not coprime with $n$ as they share a divisor. Therefore, there is no $b \in \mathbb{Z}$ such that $ab \equiv 1 \: mod \: n$ as $1$ is coprime with $n$ for all $n$.
I just saw this statement and my solution looked quite a bit different from the one given, so I am not sure if it is correct. Thanks for the feedback.