Optimal Algorithmic Approach
Boyer-Moore Voting: pick a candidate, sweep through incrementing count for a match and decrementing otherwise. When count hits 0, replace candidate.
Core Invariants & Edge Cases
- Boyer-Moore Voting Algorithm reduces to O(1) space
- Maintain a candidate and counter; increment/decrement as you scan
- Verify the candidate in a second pass if not guaranteed to exist