1/18
Loading...
🚀Start Boyer–Moore Majority Vote
We find the "majority element" (appearing more than half the time) in a single pass (O(n)) using just two variables (O(1)): a candidate and its lead count.
Loading...
We find the "majority element" (appearing more than half the time) in a single pass (O(n)) using just two variables (O(1)): a candidate and its lead count.
Boyer–Moore Majority Vote is an algorithm that, if a majority element (more than half) exists, finds it. The key is two variables — a candidate and a count — where each differing value cancels one of the candidate's votes.