Can someone explain what this question is asking for?
Array A contains n‐1 unique integers in the range [0,n‐1] and there is one number from this range that is not in A. Design an O(n) algorithm for finding that number. You are allowed to use only O(1) additional space besides the array A itself.
Does this question means the length of the array is (for example: 5). And array contains = {0,1,x,3,4}. Find x?
What is O(n) and O(1)? How do I find the missing number in the array using O(n) algorithm?
Help is appreciated. Thanks.
npossible numbers, and onlyn-1of these are in the array, so you have to find the missing one. Think about it: in the range[0,n-1], there arenunique integers.{0, 1, ..., n-1}containsnelements... there's no confusion at all