103. Find Duplicate Records
Challenge1000 ms256 MBSolved by 0%
Read n records, each holding an id and a name.
Print the id of the first record whose id has appeared before, or None if every id
is unique.
Two records with the same id count as duplicates even if their names differ.
Constraints - `1 ≤ n ≤ 200000` - `1 ≤ id ≤ 1000000000` - Names are 1 to 30 letters with no spaces.
Input
The first line contains an integer n.
Each of the next n lines contains an id and a name.
Output
Print one integer, the id of the first record whose id has appeared before, or None if every id is unique.
Input4
1 A
2 B
1 C
3 D
Output1
Notehas a repeated id with a different name, which still counts
Input3
1 A
2 B
3 C
OutputNone
Notehas no duplicates at all
Hints
Four rungs, in order. The last two open once you have submitted an attempt. A wrong one counts.
Hint 1Where to start
Hint 2The approachOpen hint 1 first. This one carries on from it.
Hint 3PseudocodeOpen hint 2 first. This one carries on from it.
Hint 4Full solutionOpen hint 3 first. This one carries on from it.