majority-1.0: Boyer-Moore Majority Vote Algorithm
Algorithms.Majority
Description
Synopsis
majority :: Eq a => [a] -> Maybe aSource
O(length xs), Determines if there in a list of votes xs is a candidate that has more than half of the votes, and if so, returns that canditate.
E.g. applying majority on the string "AAACCBBCCCBCC" yields Just 'C', since 'C' has 7 out of 13 votes.
majority
"AAACCBBCCCBCC"
Just 'C'
'C'