logo

Back to questions

Missing Integer [Amazon Python Interview Question]

Easy

Given an input list containing nn distinct numbers in the range 0 to nn, return the only number in the range that is missing from the list.

For example, given , return . Because the input list has 3 elements in it, we expect to see the numbers 0 to 3 in there, but 2 is missing.

Another example: given , return . We return becuase the input list has 4 elements in it, so we expect to see the numbers 0 to 4 in there, but 0 itself is missing!

Python