Prob. 18, Sec. 2.3, in I.N. Herstein's TOPICS IN ALGEBRA, 2nd ed: For any $n > 2$ construct a non-abelian group of order $2n$ Here is Prob. 18, Sec. 2.3, in the book Topics in Algebra by I.N. Herstein, 2nd edition:

For any $n > 2$ construct a non-abelian group of order $2n$.

Herstein gives the following hint to this question: "imitate the relations in $S_3$ (permutation group of order $3$)".
I've already seen an answer to this problem using dihedral groups, but I still couldn't solve the question based on the hint.
Despite the fact I'm asking for a particular solution, please feel free to share different ways of doing it. It will be very interesting.
Thanks in advance.

I am reading "Topics in Algebra 2nd Edition" by I. N. Herstein.
This problem is Problem 18 on p.36.
I solved this problem as follows:

Let $\phi:=\begin{pmatrix}-1&0\\0&1\end{pmatrix}$.
Let $\psi:=\begin{pmatrix}\cos\frac{2\pi}{n}&-\sin\frac{2\pi}{n}\\\sin\frac{2\pi}{n}&\cos\frac{2\pi}{n}\end{pmatrix}$.
Let $D:=\{I_2,\psi,\psi^2,\dots,\psi^{n-1},\phi,\phi\cdot\psi,\phi\cdot\psi^2,\dots,\phi\cdot\psi^{n-1}\}$.
Obviously, $\psi^i\neq\psi^j$ for $0\leq i<j\leq n$.
Obviously, $\phi\psi^i\neq\phi\psi^j$ for $0\leq i<j\leq n$.
Since $\det\psi^i=1$ and $\det\phi\psi^j=-1$, $\psi^i\neq\phi\psi^j$ for $0\leq i<j\leq n$.
So, $\#D=2n$.
$\phi^2=I_2$.
$\psi^n=I_2$.
$\phi\cdot\psi=\begin{pmatrix}-1&0\\0&1\end{pmatrix}\cdot\begin{pmatrix}\cos\frac{2\pi}{n}&-\sin\frac{2\pi}{n}\\\sin\frac{2\pi}{n}&\cos\frac{2\pi}{n}\end{pmatrix}=\begin{pmatrix}-\cos\frac{2\pi}{n}&\sin\frac{2\pi}{n}\\\sin\frac{2\pi}{n}&\cos\frac{2\pi}{n}\end{pmatrix}$.
$\psi^{-1}\cdot\phi=\begin{pmatrix}\cos\frac{-2\pi}{n}&-\sin\frac{-2\pi}{n}\\\sin\frac{-2\pi}{n}&\cos\frac{-2\pi}{n}\end{pmatrix}\cdot\begin{pmatrix}-1&0\\0&1\end{pmatrix}=\begin{pmatrix}-\cos\frac{-2\pi}{n}&-\sin\frac{-2\pi}{n}\\-\sin\frac{-2\pi}{n}&\cos\frac{-2\pi}{n}\end{pmatrix}$.
So, $\phi\cdot\psi=\psi^{-1}\cdot\phi$.
$\phi\cdot\psi^{-1}=\phi\cdot\psi^{n-1}=(\phi\cdot\psi)\cdot\psi^{n-2}=\psi^{-1}\cdot(\phi\cdot\psi^{n-2})=\cdots=(\psi^{-1})^{n-1}\cdot\phi=\psi^n\cdot(\psi^{-1})^{n-1}\cdot\phi=\psi\cdot\phi.$
$\psi^i\cdot\phi\psi^j=\phi\psi^{-i}\psi^j=\phi\psi^{j-i}$.
Since $\psi^n=I_2$, we can write $\phi\psi^{j-i}=\phi\psi^k$, where $0\leq k<n$.
So, $\psi^i\cdot\phi\psi^j\in D$.
$\phi\psi^i\cdot\psi^j=\phi\psi^{i+j}$.
Since $\psi^n=I_2$, we can write $\phi\psi^{i+j}=\phi\psi^k$, where $0\leq k<n$.
So, $\phi\psi^i\cdot\psi^j\in D$.
$\psi^i\cdot\psi^j=\psi^{i+j}$.
Since $\psi^n=I_2$, we can write $\psi^i\cdot\psi^j=\psi^k$, where $0\leq k<n$.
$\phi\psi^i\cdot\phi\psi^j=\phi\phi\psi^{j-i}=\psi^{j-i}$.
Since $\psi^n=I_2$, we can write $\phi\psi^i\cdot\phi\psi^j=\psi^k$, where $0\leq k<n$.
So, $D$ is closed under the matrix multiplication.
$\psi^i\cdot\psi^{n-i}=I_2$.
$\phi\psi^i\cdot\phi\psi^i=I_2$.
So, any element of $D$ has its inverse.
Therefore, $D$ is a subgroup of $GL(2,\mathbb{R})$.
$\psi\cdot\phi=\phi\psi^{-1}=\phi\psi^{n-1}\neq\phi\psi$.
So, $D$ is non-abelian.

