In trying to figure out the above problem I looked at Number of surjections from $\{1,...,m\}$ to $\{1,...,n\}$ and i'm fairly confused on a few things.
Following op's argument, if we look at {1...m} to {1...n} then there are
$n^m$ total functions. This makes sense to me. But these include non subjective functions where 1,2,3... elements in the co-domain have no mapping. So we subtract non subjective function:
$n \choose 1$$(n-1)^m$ -> set $S_1$ of functions missing 1 element
$n \choose 2$$(n-2)^m$ -> set $S_2$ of functions missing 2 elements.
But then op makes the comment" but how many times did we count this in the previous count?" This I don't get. These functions are ones where 2 elements in the co-domain have no input that maps to them. The previous ones consisted of functions where only 1 element in the co-domain had no input that mapped to them. So how could there be duplicates? Any function you choose from $S_1$ will differ from another in $S_2$ as functions in $S_2$ will have an additional element in co-domain with no mapping.
Also is there a way to do the given problem
Find the number of surjections from A to B if $|B|=|A|-1$
without the inclusion-exclusion thing or if not could someone explain it.