Skip to main content

Practice · 2 of 5

Find the Duplicate

CHALLENGE
Difficulty: beginner+25 XP

**Description:** Given n+1 integers, each in 1..n, exactly one value appears twice and all others appear once. Print the duplicated value. **Input:** Line 1: n (1 ≤ n ≤ 10^6). Line 2: n+1 integers (1 ≤ each ≤ n). **Output:** One integer — the duplicated value. **Example:** 4 / 1 3 4 2 3 → 3.

Back to lesson: Practice: Marking Array Set