# Problem Statement 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._ ## Constraints - `n == nums.length` - `1 <= n <= ` $10^4$ - `0 <= nums[i] <= n` - All the numbers of `nums` are **unique**. # Solution We can use the triangle number formula to find the expected sum of all numbers from 1 to $n$ and compare that with the sum of our list. The difference between the two will give us our answer. ```python n = len(nums) expected = (n*(n+1))//2 return expected - sum(nums) ``` Time Complexity: O$(n)$ | Space Complexity: O$(1)$