Missing Number
EasyBit Manipulation & Math
Decode it first. Clues, constraints, pattern and plan before any code.nums holds n distinct numbers taken from the range 0 to n, so exactly one number in that range is missing. Return it. Try for O(n) time and O(1) extra space.
nums = [3, 0, 1] → 2
nums = [0, 1] → 2 (n = 2, so the range is 0..2)
nums = [9, 6, 4, 2, 3, 5, 7, 0, 1] → 8Constraints
n == nums.length1 <= n <= 10^40 <= nums[i] <= n- All the numbers of
numsare unique.