Most Frequent Value — Solution & Editorial
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.
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.