Missing From a Range
nums holds every integer from lo to hi (both included) exactly once, except for one integer that is missing. The order is scrambled. Return the missing integer. nums has hi - lo items, so exactly one value of the range is absent.
Example 1
nums [3,1,4]
lo 1
hi 4
returns 2
The range 1 to 4 is 1, 2, 3, 4 and the list lacks 2.
Example 2
nums [2,3]
lo 1
hi 3
returns 1
The range 1 to 3 is 1, 2, 3 and the list lacks 1.
Constraints
0 <= lo < hi <= 1000hi - lo <= 100len(nums) == hi - lo- every item of
numsis betweenloandhiand no item repeats
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.