Back to Question

Boyer-Moore Majority Vote Algorithm

Question Explain

Given an array `nums` of size $n$, return the majority element (the element that appears more than $\lfloor n/2 \rfloor$ times). The algorithm should run in $O(n)$ time and $O(1)$ space.

Start Trying This Question Simulation

Click "Start Speaking" and answer the question naturally.