Problem · Array
Most Frequent Integer with Smaller Tie-Break
Learn this problemProblem statement
Given an integer array nums, return the value that appears most frequently.
If multiple values have the same maximum frequency, return the smallest of those values.
Function
mostFrequentInteger(nums: int[]) → intExamples
Example 1
nums = [4, 2, 4, 2, 3]return = 2The values 2 and 4 each appear twice. Because their frequencies tie, return the smaller value, 2.