Hints:
Declare an array with size 1001 for counting the input numbers...
Today, Rock found an array of integers in his cupboard. Help Rock calculate the mode of this array.
The mode of an array is defined as the element with the highest number of occurrences in the array. If there are multiple such elements, the mode is undefined.
Input
The first line of input contains an integer $n$, the size of the array $A$.
The second line of input contains $n$ integers, $A_1, \cdots, A_n$.
Output
If the mode exists, output the mode.
Otherwise, output undefined
.
Constraints
For all cases, $1 \le n \le 10^5$ and $0 \le A_i \le 10^3$.
Subtask 1 (60%): The mode is guaranteed to exist.
Subtask 2 (40%): The mode may not exist.
Sample Test Cases
Input | Output | |
---|---|---|
8 5 5 1 3 9 0 4 5 |
5 | |
4 2 3 3 2 |
undefined |
Scoring: Per Subtask
Authored by s16f22
Appeared in 2024 Mini Contest 1