So we are given:
$$
f(x) = \cases {
x-1 & x $\text{ even}$ \\
2x & x $\text { odd}$ \\
}
$$
Now, you can see this function is injective. However, we claim it is surjective, and this is the reason why:
Let $l$ be an integer.
Suppose $l$ is odd, then $l+1$ is even, right? And from the definition of $f$, we see that $f(l+1) = (l+1)-1 = l$. So, for $l$ odd, we would like the inverse to be $l+1$.
Let $l$ be even, then $\frac{l}{2}$ is well-defined, and $f(\frac l2) = 2 \times \frac l2 = l$.So for $l$ even, we would like the inverse to be $\frac l2$.
Hence, we see that $f$ is surjective. However, the inverse mapping is given by the surjectivity:
$$
g(l) = \cases{
l+1 & $l \text{ odd}$ \\
\frac l2 & $l \text{ even}$ \\
}
$$
Why has the flipping happened? Simple. Both operations (adding $1$, multiplying by $2$) change the odd/even parity of the number (multiplying by $2$ happens only for odd numbers in the definition of $f$, so that all numbers change parity). Any inverse so involved will have to restore this parity (because you get back the same number, so the parity has to be the same, right?). Hence, any odd number will have to go to an even number, and every even number will have to go to an odd number (upon left-composition).
We will verify the inversion.
Suppose $l$ is odd, then we get $f(l) = 2l$, which is now even, so that $g(f(l))= l$.
Suppose $l$ is even, then we get $f(l) = l -1$, which is odd, so that $g(f(l))= l$.
Hence, $g$ is the correct left inverse of $f$.