Find Missing Number
EasyArrayStringBit ManipulationMATH
You are given an array containing n distinct numbers taken from the range 0 to n.
This means one number in the range is missing from the array.
Your task is to return the missing number.
Constraints:
The array contains n numbers and all are unique.
The numbers are in the range [0, n], so exactly one number is missing.
1 ≤ n ≤ 10⁴
Examples
Example 1
Input: [3, 0, 1]
Output: 2
Example 2
Input: [0]
Output: 1