I know how $fg$ works, and I know how to get the target matrix, but I don't understand how to get $(124)(35)$ before the matrix.
Please enlighten me the detailed process.
\begin{equation} f=\left(\begin{array}{ll} 1 & 3 \end{array}\right)(45)=\left(\begin{array}{lllll} 1 & 2 & 3 & 4 & 5 \\ 3 & 2 & 1 & 5 & 4 \end{array}\right) \end{equation}
\begin{equation} g=\left(\begin{array}{lll} 1 & 2 & 5 \end{array}\right)\left(\begin{array}{ll} 3 & 4 \end{array}\right)=\left(\begin{array}{lllll} 1 & 2 & 3 & 4 & 5 \\ 2 & 5 & 4 & 3 & 1 \end{array}\right) \end{equation}
\begin{equation} f g=f \circ g=\left(\begin{array}{lll} 1 & 2 & 4 \end{array}\right)(35)=\left(\begin{array}{lllll} 1 & 2 & 3 & 4 & 5 \\ 2 & 4 & 5 & 1 & 3 \end{array}\right) \end{equation}
Similar confusion:
\begin{equation} (143)(23)(24)=(14)(23) \end{equation}
I think the best way is to simply compute the cycles? For each values 1 through 5, simply see what $fg$ sends them to. $$ 1 \stackrel{g}{\to} 2 \stackrel{f}\to 2 \stackrel g \to 5 \stackrel f \to 4 \stackrel{g}\to 3 \stackrel f \to 1 $$ so your first cycle will be $(1 \, 2 \, 4)$. Your second cycle is $$ 3 \stackrel g\to 4 \stackrel f \to 5 \stackrel g \to 1 \stackrel f \to 3 $$ so your second cycle is $(3 \, 5)$. Thus $fg = (1\,2\,4)(3\,5)$.
Hope that helps.