A turnstile logs badge ids in scans as people enter. A badge that is scanned twice is suspicious. Return the badge id whose second scan happens earliest. If no badge is scanned twice, return None.
Examples
Input: scans = [3, 1, 3, 1]
Output: 3
Explanation: 3 is scanned again at position 2, before 1 is scanned again at position 3.
Input: scans = [2, 5, 5, 2]
Output: 5
Constraints
0 <= len(scans) <= 10**5- Target complexity: O(n) time.
Goals
- Use a set to remember what has been seen
- Stop at the earliest second occurrence