Statistical Mode
EasyStatisticsMathArrayHash Table
Description
Given an array of integers, return the mode: the value that appears most frequently. If several values are tied for the highest frequency, return the smallest of them.
Examples
Input:
[1,2,2,3]Output:
2Explanation:
The value appearing most often is the mode, and when several values share the highest frequency the smallest of them is chosen.
Input:
[4,4,1,1]Output:
1Explanation:
The value appearing most often is the mode, and when several values share the highest frequency the smallest of them is chosen.
Input:
[5]Output:
5Explanation:
The value appearing most often is the mode, and when several values share the highest frequency the smallest of them is chosen.
Constraints
- •
1 ≤ array length ≤ 10⁴