Practice · 3 of 5
The Missing Number
CHALLENGE
Difficulty: beginner+25 XP
**Description:** The numbers 1..n should all be present, but exactly one
is missing. Print it.
**Input:** Line 1: n (2 ≤ n ≤ 10^6). Line 2: n−1 integers — the present ones.
**Output:** One integer — the missing number.
**Example:** 5 / 1 2 4 5 → 3.
*Two solutions exist:* a marking array, or the sum trick
(missing = n(n+1)/2 − sum). Both are worth writing.
Press Submit to check your solution.
Back to lesson: Practice: Marking Array Set