## Riverbed Interview Question

Software Engineer / Developers**Country:**United States

I don't think this works, a negative test case for your code is :

1, 2 , 9997,9999, 9999

10000, 10001, 19997, 19999,19999

etc.

this means 9998 is always missing but 9999 always duplicated, so your algorithm doesn't work.

Unless the interviewer says the numbers are unique.

Now first of all you must note something even though it says 10billion you can have only 4billion distinct integers (2^32). S if we had 500MBmemory we could have mapped each of these integers to a bit vector.

Since we have less memory vijay's solution should be used.

As a last note this is actually a question from the book and both of these solutions are discussed in depth.

Now first of all you must note something even though it says 10billion you can have only 4billion distinct integers (2^32). S if we had 500MBmemory we could have mapped each of these integers to a bit vector.

Since we have less memory vijay's solution should be used.

As a last note this is actually a question from the book and both of these solutions are discussed in depth.

Now first of all you must note something even though it says 10billion you can have only 4billion distinct integers (2^32). S if we had 500MBmemory we could have mapped each of these integers to a bit vector.

Since we have less memory vijay's solution should be used.

As a last note this is actually a question from the book and both of these solutions are discussed in depth.

Are those integers supposed to be continuous? If yes, you need only O(1) memory and O(N) complexcity. The algo is:

1. Sum all the integers from the given array and store it as A.

2. Calculate the expected number via this equation: B = (min + max) * number / 2;

3. The missing number is B - A

I'll solve a simplified version of the problem. You should be able to extend it to solve your problem.

You have a large number of integers between 1 to 100000 in a file. However, you can only store a single array of length. How do you find an integer on in that file.

Hope you get the idea. Sorry about the horrible pseudocode!

- vijay January 15, 2012