108. Find the Duplicate Token

Acceptance — 0 accepted 0 submissions

Medium
ArraysHashing
No companies listed
A hospital gives tokens numbered 1 to n. By mistake, one token number was printed twice, so there are n + 1 tokens.

Find the token number that appears twice.

Input Format
The first line has n.
The second line has n + 1 integers, each from 1 to n.

Output Format
Print the duplicated number.

Constraints
• 1 ≤ n ≤ 10^5
• Exactly one number appears twice, and every other number appears once.

Example 1

Input
4
1 3 4 2 2
Output
2

Explanation Token 2 appears twice.

Example 2

Input
1
1 1
Output
1

Explanation Only one token number, printed twice.

Example 3

Input
5
5 1 2 5 3 4
Output
5

Explanation Token 5 is the repeat.

Acceptance —
Accepted 0
Submissions 0
Auto-save
Saved Ln 1, Col 1
Submit a solution to see its status here.
Input
Expected Output
2
No results yet
Run your code to test it against the sample cases.
Problem List