Loading...
Loading...
Loading...
Tickets arrive one by one. A ticket id is a duplicate when the same id has already arrived earlier.
Print the first id that turns out to be a duplicate, reading from left to right. If no id repeats, print None.
None.Example
Input
T4 T2 T7 T2 T4
Output
T2
T2 repeats before T4 does.
Try the problem first. Open one hint at a time.
Keep the ids you have already seen in a set.
For each id, if it is already in the set print it and stop. Otherwise add it. Use for-else for the None case.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor