cheetcode

148. Missing NumberEasy

Find the missing value from a range of 0 through n.

Given an array nums containing n distinct numbers in the range [0, n], return the one number that is missing from the array.

Examples

Input: nums = [3,0,1]
Output: 2
Input: nums = [0,1]
Output: 2

Constraints

  • 1 <= nums.length <= 10,000
  • 0 <= nums[i] <= n
  • All values are unique.