【Example 4】A person's matchbox contains $n$ red, green, and black-tipped matches each. Each time, one is taken at random. When the black-tipped matches are all used up, it is found that there are $r$ red and $g$ green matches left. Find the number of different ways this outcome can occur.
This person used a total of $n+(n-r)+(n-g)=3n-r-g$ matches. In the first $3n-r-g-1$ uses, black, red, and green matches should have been used $n-1$, $n-r$, and $n-g$ times, respectively. Therefore, there are
$$
\binom{3n-r-g-1}{n-1 \, n-r \, n-g}=\frac{(3n-r-g-1)!}{(n-1)!(n-r)!(n-g)!}
$$

different cases.
This example is frequently cited in classical probability, and it is related to the so-called "Banach's matchbox problem."

The permutation pattern of indistinguishable elements can be used not only in situations where elements are truly indistinguishable but also in situations where the order of certain different elements is strictly specified.