Let $f: A\to B$ and $g,g' : B \to C$. Prove that if $g \circ f=g' \circ f$ and $f$ is surjective then $g=g'$.
Is it fair to say that since $f$ is surjective it has a right inverse such that $f\circ f^{-1}= \text{Id}_B$ and thus $$ g\circ f\circ f^{-1}=g'\circ f\circ f^{-1} $$ which implies $g \circ (\text{Id}_B) = g'\circ (\text{Id}_B)$ and thus $g=g'$?
Proof by contrapositive:
Suppose that $g \neq g'$ and that $f$ is surjective (we want to conclude $g \circ f \neq g' \circ f$).
There exists an element $b \in B$ such that $g(b) \neq g'(b)$. Because $f$ is surjective, there exists an $a \in A$ such that $f(a) = b$.
Because $g(f(a)) \neq g'(f(a))$, we conclude that $g \circ f \neq g' \circ f$.