Union of subgroups is a subgroup if and only if one subgroup is a subset of the other [duplicate]

Let $H$ and $K$ denote two subgroups of a group $G$. Prove that the union $H \cup K$ is a subgroup of $G$ if and only if $H \subset K$ or $K \subset H$.


I shall use multiplicative notation for the group law.

If $H$ or $K$ is the trivial subgroup $\{1\}$ consisting only of the multiplicative identity, the result is trivial. So, take $H, K$ to be subgroups of $G$ such that $H,K \neq \{1\}$.

$\Leftarrow$ If WLOG $H \subset K$, then $H \cup K=K$. Because $K$ is a subgroup of $G$, $H \cup K$ is a subgroup of $G$.

$\Rightarrow$ Suppose for sake of contradiction that we have neither $H \subset K$ nor $K \subset H$ but that $H \cup K$ is a subgroup of $G$. This implies that there exists $h \in H$ such that $h \notin K$; likewise, $\exists k \in K$ such that $k \notin H$. Because $H \cup K$ is a subgroup of $G$, $hk \in H \cup K$, which implies $hk \in H \vee hk \in K$. Say, WLOG, $hk \in H$. Well, since $h \in H$, $h^{-1} \in H$. Thus, $h^{-1}hk=k \in H$, contradiction.