If $f$ is a function $A\to A$ where $A$ is a finite set, then $f$ is injective if and only it it is surjective. It is not possible for such an $f$ to be injective without being surjective or vice versa.
This can be proved by induction on the number of elements in $A$, but the details are slightly tedious. This property carries over to a function $f:A\to B$ where $A$ and $B$ have the same number of elements -- because "the same number of elements" means that there is a bijection $g:A\to B$, and then $f$ is injective/surjective exactly when $g^{-1}\circ f$ is, and $g^{-1}\circ f$ goes from $A$ to $A$ itself.
On the other hand, if $A$ is infinite, then it is possible for a function to be injective without being surjective, or vice versa. Some simple examples for $\mathbb N\to\mathbb N$ is
$$ g(n) = n+7 \\
h(n) = \begin{cases} n & \text{if }n\le 42 \\ n-1 & \text{otherwise} \end{cases}$$
where $g$ is injective but not surjective, and $h$ is surjective but not injective.
(Strictly speaking this property of infinite sets is only guaranteed if the axiom of choice holds, but that is a techincal complication that you probably don't want to worry about at this level).
It all depends on the co-domain of your function.
When you have a function $$f:A\to B$$ which is one-to-one but not onto $B$, you may restrict your co-domain to a subset of $B'\subset B$ which is the range of $f$.
For example $$f:N \to N $$ defined by $$f(n)=2n$$ is not onto but it is one-to-one.
If we define, $$f^* : N\to 2N$$ with the same definition $f^*(n)=2n$
We have an inverse function, $(f^*)^{-1} (n) = n/2.$
Best Answer
That depends on subtleties of your definition of inverse function. If you expect a function $f\,:\, A \to B$ to have an inverse $f^{-1} \,:\, B \to A$, then $f$ needs to be surjective. If it is not, there are some $b \in B$ that aren't reached by $f$ at all, so how would you define $f^{-1}$ for such elements of $B$?
However, any injective $f\,:\, A \to B$ can be made surjective by simply restricting $B$, i.e. by setting $\widetilde{B} = \{f(a)\,:\, a\in A\}$ and redefining $f$ as $f \,:\, A \to \widetilde{B}$. That redefined $f$ then has an inverse $f^{-1} \,:\, \widetilde{B} \to A$.
Note, however, that while this makes the concatenation $f^{-1} \circ f$ the identity funtion on $A$, it does not make $f \circ f^{-1}$ the identity function on $B$, only on $\widetilde{B} \subsetneq B$.
Thus, if $f \,:\, A \to B $ is injective but not surjective, it has a left-inverse, because we can find an $f^{-1}$ as above with the property that $f^{-1} \circ f$ is the identity on $A$. But it does not have a right-inverse, because we won't find a $f^{-1}$ such that $f \circ f^{-1}$ is the identity on $B$ - the best we can achieve is an identity on $\widetilde{B}$.
Similarly, if $f \,:\, A \to B$ is surjective but not injective, it has a right-inverse, but no left-inverse.