Let $f: X\longrightarrow Y$ and $g: Y\longrightarrow Z.$
Show that $f : X\longrightarrow Y$ is bijective if and only if there exists $g: Y \longrightarrow X$ with $g \circ f = \operatorname{id}_X$ and $f \circ g = \operatorname{id}_Y.$ What happens if you drop one of the two conditions on $g$?
I needed help in constructing simple counterexamples to bijectivity of $f$ in either case.
What I have so far:
Define $g : Y \longrightarrow X$ by $g(f(x)) = x$ for all $x \in X.$ To show that $g$ is well-defined, suppose $f(c)$ and $f(d)$ are the same, but $c$ and $d$ are different (i.e. $f$ isn't injective); that is, let $y = f(c) = f(d),$ where $c \neq d.$ Then $g(y) = g(f(c)) = c,$ and also $g(y) = g(f(d)) = d.$ Hence, $c = d,$ which is a contradiction by the injectivity of $f.$
That $g \circ f = \operatorname{id}_X$ is true by the way we defined $g.$
As for $f \circ g = \operatorname{id}_Y:$
$$\begin{align*} f(g(y)) &= f(g(f(x)) &&\text{for some }x \in X\text{ (since }f\text{ is surjective)}\\ &= f(x) &&\text{(since }g\circ f=\mathrm{id}_X\text{)}\\ &= y \end{align*}$$ as required.
Conversely, suppose there exists $g : Y \longrightarrow X$ with $g \circ f = \operatorname{id}_X$ and $f \circ g = \operatorname{id}_Y.$ Since $f \circ g = \operatorname{id}_Y$ is onto, part a) allows us to conclude that $f$ is surjective (onto). Since $g \circ f = \operatorname{id}_X$ is 1-1, part a) allows us to conclude that $f$ is injective (1-1).
Hence, $f$ is a bijection.