Show that $f$ is an epimorphism of groups if and only if $f$ is surjective as a map of groups. A homomorphism between groups, $f:H\to K$ is said to be an epimorphism if for any group $L$, and for any homomorphisms $u,v:K\to L$, we have $u\circ f=v\circ f$ holds if and only if $u=v$ holds. Show that $f$ is an epimorphism of groups if and only if $f$ is surjective as a map of groups.
Firstly, suppose $f$ is surjective, we can know the image of $f$ is the entire $K$, so $u\circ f=v\circ f$ can imply $u=v$. Also $u=v$ can also imply $u\circ f=v\circ f$.
But how can I prove another way? Can someone tell me how to prove it? Or,can someone give me some hints? 
 A: I know this is an old question, but this came up recently in an answer to another question, so I figure we might as well have a standard answer on the site.
A classic proof of this fact is due Schreier; he used free products with amalgamation. He then also deduced the nontrivial fact that epimorphisms are surjective in the category of finite groups.
Carl Linderholm (of Mathematics Made Difficult fame) published a 1 page elementary proof in "A Group Epimorphism is Surjective", in the American Mathematical Monthly 77, pp. 176-177. I gave the proof on sci.math back in 2000. This is this proof with slightly different notation.
Let $f\colon H\to K$ be an epimorphism. We seek to find a group $S$ and two morphisms $g,h\colon K\to S$ such that $gf=hf$, and then use the conclusion that $g=h$ to conclude that $f(H)=K$.
Let $X=K/f(H)$ be the set of right cosets of $f(H)$ in $K$. Let $\infty$ be something which is not an element of $X$, and let $Y=X\cup\{\infty\}$. Let $S$ be the group of permutations on $Y$.
The right action of $K$ on $X$ induces an embedding of $K$ into $S$ as permutations that fix $\infty$; call this map $g$. Now let $\sigma\in S$ be the permutation that exchanges the coset $f(H)$ with $\infty$ and fixes everything else. let $h\colon K\to S$ be the homomorphism we get by composing $g$ with conjugation by $\sigma$ in $K$.
Now, consider $h$ and $g$. If $x\in H$, then $f(x)$ fixes the coset $f(H)$ and fixes $\infty$. Thusm the support of $g(f(x))$ and $\sigma$ are disjoint hence they commute: $h(f(x))=\sigma^{-1}\circ g(f(x))\circ \sigma=g(f(x))$. That is, $h\circ f = g\circ f$.
Since $f$ is an epimorphism, we conclude that $h=g$.
But that means that for all $k$, $h(k)=g(k)$. In particular, $g(k)$ must commute with $\sigma$ for all $k$. This requires
that $g(k)$ leave $f(H)$ fixed. But that requires $k\in f(H)$. That is, we must have $f(H)=K$, so $f$ is surjective, as claimed.
Note, along the way, that when $K$ is finite the group $S$ is also finite. So this also proves that epimorphisms are surjective in the category of all finite groups, something which is not immediately obvious from Schreier’s Theorem. However, Schreier’s Theorem is stronger than the assertion that epimorphisms are surjective: it proves that every subgroup is an equalizer subgroup; i.e., if $H\leq G$, then there exist a group $K$ and morphisms $f,g\colon G\to K$ such that the equalizer of $f$ and $g$ is exactly $H$: $\mathrm{Eq}(f,g)=\{x\in G\mid f(x)=g(x)\}=H$. 
A: 
Firstly, suppose $f$ is surjective, we can know the image of $f$ is the entire $K$, so $u\circ f=v\circ f$ can imply $u=v$.

I take issue with the first sentence of your proof, quoted above.  At the very least, the reasoning is not clear to me: where did you use surjectivity?
You want to show that $u = v$ as functions $K \to L$, so you might proceed by choosing an arbitrary $k \in K$ and showing that $u(k) = v(k)$.  Since $f$ is surjective, what can you say about $k$?
Phrased a bit differently, you could instead say that $u \circ f = v \circ f$ implies that the restrictions $u|_{\text{img}(f)} = v|_{\text{img}(f)}$, and then use your observation about the image of $f$.
A: Here is an alternative answer to this old question.
The key point is to show the following:

Given a subgroup $H$ of a group $G$, there is a group $K$ and homomorphisms $a, b:G\to K$ such that $a(g)=b(g)$ if and only if $g$ lies in $H$.

Consider the set $S=G/H$ with the natural action of $G$ on it. This induces a natural action of $G$ on the power set $P$ of $S$. We have a distinguished point $H$ of $S$ which is fixed precisely by $H$.
The group $K=\mathrm{Perm}(P)$ consists of bijections of $P$ with itself. The homomorphism $a$ is the one associated with the above action.
The power set $P$ is the disjoint union of two subsets $P_0$ and $P_1$, where $P_0$ consist of subsets of $S$ that contain $H$, respectively $P_1$ consists of subsets of $S$ that do not contain $H$. There is an involution $k\in K$ on $P$ which interchanges elements of $P_0$ with $P_1$ by adding/removing $H$ from the subset as required.
The homomorphism $b$ is given by $b(g)=k a(g) k$. Now, $k(\{H\})=\emptyset$ and clearly $a(g)(\emptyset)=\emptyset$ so that $ka(g)k(\{H\})=\{H\}$. On the other hand $a(g)(\{H\})=\{gH\}$. So if $g\not\in H$, then $a(g)\neq b(g)$.
(This proof does not seem particularly different from the one given by Arturo Magidin except that the action seems a little more "canonical". On the other hand, Arturo's proof could perhaps be seen as an application of the "Maybe Monad" which is simpler than the "PowerSet Monad"!)
