With this code I can find most occurrences of items in an array:
letters.max_by { |i| letters.count(i) }
But this will return 2
for
a = [1, 2, 2, 3, 3]
although 3
has the same occurrence. How can I find out, if there really is an item with most occurrences? I would like to get false
if there is no single champion.