9. Missing Number
easymatharray
nums contains n distinct numbers taken from the range [0, n]. Exactly one number in that range is missing. Return it.
Example 1
Inputnums = [3,0,1]
Output2
Example 2
Inputnums = [0,1]
Output2
Example 3
Inputnums = [9,6,4,2,3,5,7,0,1]
Output8
Constraints
- 1 ≤ n ≤ 10⁴