Find the Missing Number
Easyjavapythonccppjavascript
An array contains N-1 distinct numbers taken from 1 to N, with exactly one number missing. Find the missing number.
Input Format
The first line contains an integer N. The second line contains N-1 space-separated distinct integers, each between 1 and N.
Output Format
Print the missing number.
Example 1
Input
5 1 2 4 5
Output
3
Explanation: The numbers 1..5 should be 1 2 3 4 5, so 3 is missing.
- 2 <= N <= 100000
- Exactly one number from 1..N is missing.