Solution to Abstract Algebra by Dummit & Foote 3rd edition Chapter 2.1 Exercise 2.1.8
Let $H$ and $K$ be subgroups of $G$. Prove that $H \cup K$ is a subgroup if and only if $H \subseteq K$ or $K \subseteq H$.
Solution: The ($\Leftarrow$) direction is clear.
To see ($\Rightarrow$), suppose that $H \cup K$ is a subgroup of $G$ and that $H \not\subseteq K$ and $K \not\subseteq H$; that is, there exist $x \in H$ with $x \notin K$ and $y \in K$ with $y \notin H$. Now we have $xy \in H \cup K$, so that either $xy \in H$ or $xy \in K$.
If $xy \in H$, then we have $x^{-1}xy = y \in H$, a contradiction. Similarly, if $xy \in K$, we have $x \in K$, a contradiction. Then it must be the case that either $H \subseteq K$ or $K \subseteq H$.