Problems > Most Frequent Value > Editorial

Most Frequent Value — Solution & Editorial

Back to the Problem

Count occurrences with a hash map, find the maximum count, then take the smallest value achieving it.

Complexity: O(N)

Watch out: The tie-break asks for the smallest value, not the first one seen.