Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array.
Input: nums = [3, 0, 1]
Output: 2
Input: nums = [0, 1]
Output: 2
Input: nums = [9,6,4,2,3,5,7,0,1]
Output: 8
n == nums.length1 <= n <= 10^40 <= nums[i] <= nnums are unique.When the function findMissingNumber is called with the given example inputs, the expected output is the missing number in the array.
console.log(findMissingNumber([3, 0, 1])); // Output: 2
console.log(findMissingNumber([0, 1])); // Output: 2
console.log(findMissingNumber([9,6,4,2,3,5,7,0,1])); // Output: 8
Memory: 0
CPU: 0