The Missing Number
nums contains distinct numbers taken from . Exactly one is missing; return it.
Requirements
- time and extra space. Use or XOR.
Examples
EXAMPLE WALKTHROUGHmiddle missing
A guided view of the published example, not a trace of your code.
INPUT
[[3,0,1]]TASKthe_missing_number()
EXPECTED OUTPUT
2Start with the input values shown in this example.
Example 1 of 3
Input: nums = [3,0,1]
Output: 2
Explanation: middle missing
Input: nums = [0,1]
Output: 2
Explanation: last missing
Input: nums = [1]
Output: 0
Explanation: zero missing
Hint 1
Subtract the actual sum from the expected sum.