72. Elements More Than n/3 Times
MediumCounting
Print all values that appear more than ⌊n/3⌋ times, in increasing order, or -1 if there are none.
Input format
Line 1: n Line 2: n integers
Output format
The values, or -1.
Example 1
Input
3 3 2 3
Output
3
Example 2
Input
1 1
Output
1
Constraints
1 ≤ n ≤ 10⁵
Read input from standard input and print the answer to standard output. Your code is judged against 6 test cases, most of them hidden.
Loading the MyLoginn IDE…