81. First Repeating Element
EasyHash Map
Print the first element (by position) that occurs more than once in the array, or -1 if all are distinct.
Input format
Line 1: n Line 2: n integers
Output format
The value, or -1.
Example 1
Input
7 10 5 3 4 3 5 6
Output
5
Example 2
Input
3 1 2 3
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…