Let $k>n\ge1$ be integers.
I have to estimate the number of choices for the numbers $x_1,\dots,x_k$, supposing that $1\le x_j\le p$, for an integer $p$ and that there are at most $n-1$ distinct numbers between the $x_j$'s.
So, let's count: having at most $n-1$ distinct numbers, imply that I have to choose at most $n-1$ values between $1$ and $p$. Thus $p^{n-1}$.
Next I have to count all the different choices I can take for my $x_j$'s: therefore I have to count in how many ways I can assign $n-1$ values to $k$ objects: this should be the number of positive integer solutions $(y_1,\dots,y_{n-1})$ to the equation $y_1+\cdots+y_{n-1}=k$.
This is the missing link between me and the estimate written in the book, which is $n^kp^{n-1}$.
Can somebody help me please? Thanks