The missing number
Easyarraymathbit manipulation
nums holds n distinct numbers from the range 0 to n, so exactly one is missing. Return it.
Example 1
Input: nums = [3,0,1] Output: 2
Example 2
Input: nums = [0,1] Output: 2
Constraints
- 1 ≤ n ≤ 10⁴
- All numbers are distinct
Submit checks your solution against 7 tests, including hidden ones.
/**
* @param {int[]} nums
* @return {int}
*/
function missingNumber(nums) {
}