Majority Element — Solution & Editorial
Count with a hash map (or use Boyer–Moore voting) and verify the winner's count exceeds N/2.
Complexity: O(N)
Count with a hash map (or use Boyer–Moore voting) and verify the winner's count exceeds N/2.
Complexity: O(N)