Missing Number

You are presented with an array of n-1 distinct numbers, ranging from 1 to n. In other words, all the numbers from 1 to n, except one. You are allowed to read the array only once (consider a stream input with no memory) and you have O(log(n)) space. How can you find the missing number?

Solution

Password:
Back to Index