
Remove Nth occurrences
Given an array \$A\$ of positive integers between \$1\$ and \$9\$ inclusive and a positive integer \$n\$, remove all integers in \$A\$ which appear more than \$n\$ times.
For example:
[1,2,3,2,3,2,4,1,2], n = 2
Occurrence: 1 1 1 2 2 3 1 2 4
Keep? 1 1 ...