What is the quickest way to count the maximum number of duplicates in a list? For example, the maximum number of duplicates in {1,1,1,3} is 3, in {1,1,2,2} is 2 and in {1,1,1,2,2,2,3,3} is 3. I've unsuccessfully tried combinations of Commonest, Count and CountDistinct. Other questions have dealt with identifying or deleting duplicates rather than counting them.
$\begingroup$
$\endgroup$
2
lst = {1, 1, 1, 2, 2, 2, 3, 3};
ClearAll[f]
f = Max[Counts @ #] /. 1 -> 0 &;
f @ lst
3
f @ {1,2,3,4}
0
Tally
. For example,MaximalBy[Tally[lst], Last]
. $\endgroup$ – Henrik Schumacher Jun 1 '19 at 12:03