GreedyEvidence Contributing
Boyer-Moore Voting Algorithm
Maintain a single candidate and a counter, incrementing on a match and decrementing otherwise, to find a majority element in one pass with O(1) space.
Practice Problems: 1
Difficulty: 1 Easy·0 Medium·0 Hard
Core technique
Review the technique, then try the mapped problems below. The right approach depends on each problem's constraints.
- Core Strategy: Maintain a single candidate and a counter, incrementing on a match and decrementing otherwise, to find a majority element in one pass with O(1) space.