59. The Missing Number
Core1000 ms256 MBSolved by 0%
The array holds n distinct values taken from 1 to n + 1, in any
order, with exactly one value from that range missing.
Print the missing value.
Constraints - `1 ≤ n ≤ 200000` - All values are distinct and between 1 and n+1.
Input
The first line contains an integer n.
The second line contains n space-separated integers.
Output
Print one integer, the missing value.
Input4
1 2 4 5
Output3
Noteis missing a value from the middle
Input4
2 3 4 5
Output1
Noteis missing the very first value
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.