A warehouse dock scanner logs every pallet barcode that passes through during a shift, producing a sequence of exactly 2n scans. Among these scans there are exactly n+1 distinct barcodes: n of them belong to single-use pallets, each scanned exactly once, while the remaining barcode belongs to a reusable shuttle pallet that cycles back through the dock and is scanned exactly n times. Given the scan log, identify the shuttle pallet's barcode.
The first line contains a single integer n.
The second line contains 2n space-separated integers, the barcodes in the order they were scanned.
Print a single integer: the barcode of the shuttle pallet (the one scanned exactly n times).
Example 1
Input
4 5 7 3 7 9 7 1 7
Expected
7
Explanation
There are 2n=8 scans and n+1=5 distinct barcodes: 5, 7, 3, 9, 1. Barcode 7 appears four times (n=4) while 5, 3, 9, and 1 each appear exactly once, so 7 is the shuttle pallet.
Example 2
Input
2 10 20 10 30
Expected
10
Explanation
There are 2n=4 scans and n+1=3 distinct barcodes: 10, 20, 30. Barcode 10 appears twice (n=2) while 20 and 30 each appear exactly once, so 10 is the shuttle pallet.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →