Loading...
Loading...
Loading...
Tickets are scanned at a gate. Print the first ticket number that has already been scanned before, reading left to right. If no ticket repeats, print -1.
Example 1
Input
6 4 2 7 2 4 9
Output
2
2 repeats first, at position 3.
Example 2
Input
3 1 2 3
Output
-1
Try the problem first. Open one hint at a time.
Keep the tickets you have seen in a set.
The first ticket already in the set when you reach it is the answer.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor