318. Appearing Exactly Twice
Foundation1000 ms256 MBSolved by 0%
Print every value appearing exactly twice, in increasing order. Print None
if there is no such value.
Exactly twice. A value appearing three times does not qualify, which is the
distinction this problem exists to make: the condition is count == 2, not
count > 1.
Constraints - `1 ≤ n ≤ 200000` - `-1000000000 ≤ a[i] ≤ 1000000000`
Input
The first line contains an integer n.
The second line contains n integers.
Output
Print the qualifying values in increasing order separated by single spaces, or None.
Input6
1 2 2 3 3 3
Output2
Notehas one value twice and another three times, and only the first qualifies
Input3
1 2 3
OutputNone
Noteis all distinct
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.