Loading...
Loading...
Loading...
Orders arrive in sequence, each with an id. Print the id of the first order whose id has already been seen earlier. If every id is new, print -1.
Example 1
Input
41 17 8 17 41 99
Output
17
Example 2
Input
1 2 3
Output
-1
Try the problem first. Open one hint at a time.
Keep a set of ids seen so far.
Stop at the first id that is already in the set.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor