Missing Number
Given an array nums containing n distinct numbers from the range [0, n], return the only number in that range that is missing.
Given an array `nums` containing `n` distinct numbers from the range `[0, n]`, return the only number in that range that is missing.
- `1 <= nums.length <= 10^4` - `0 <= nums[i] <= nums.length` - All values are distinct. - The interactive visualizer accepts at most 20 values; longer valid arrays are execution-only.
Example 1: input nums = [3,0,1]; output 2. The complete range is 0 through 3; only 2 is absent.
Example 2: input nums = [0,1]; output 2. The missing value may be the upper endpoint n.
Category: Bit Manipulation. Topic: arrays. Difficulty: Easy. Patterns: bit-manipulation.