Easy15 pts
Find Missing Number
Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one number that is missing from the array. Use the sum formula: sum(0 to n) = n*(n+1)/2 Example: [3,0,1] → Missing is 2 (expected: 0,1,2,3)
Input
Line 1: n. Line 2: n space-separated integers.
Output
The missing number.
Sample
3 3 0 1
Expected
2
Loading editor…
Output
No output yet. Run your code to see results.