Most frequent element
Write a function that takes a collection and returns the most frequent element. But here's the thing: you can't use the built-in function
clojure.core/frequencies. And if there are ties, just pick one.
(most-frequent [2 2 3 4 4 2 1 1 3 2]) ;=> 2 (most-frequent ) ;=> nil (most-frequent [1 1 4 4 5]) ;=> 4
nilfor an empty collection
- in the case of a tie, return one of the winners
Please submit your solutions as comments on this gist.