How many finite sequences with exactly k different elements?

95 Views Asked by At

How many different sequences/strings of length $\ell$ contain exactly $k$ (out of $n$) different elements?

Or, to put it differently, how many functions from $\{1,\dots,\ell\}$ to $\{1,\ldots,n\}$ have the property that their image is of size exactly $k$?

1

There are 1 best solutions below

0
On BEST ANSWER

First choose the $k$ elements, in $\binom{n}{k}$ ways, then count the number of surjective functions from $\{1,\dotsc, \ell\}$ to those $k$ elements, in $k!S(\ell,k)$ ways (see here).