Facebook Interview Question: First question: for a random-... | Glassdoor

Interview Question

Software Development Engineer Interview Palo Alto, CA

First question: for a random-ordered bucket of numbers

  1 through 3000 with one number missing, how would you detect which number is missing?

Interview Answer

4 Answers


bubble sort it and stop at the first number that >1 than the previous number already sorted number.
you found the gap !

Serban Moisei on Jul 14, 2010

Compute the sum of 1 to 3000, call this number N. Then compute the sum of the bucket of numbers, call this number S.

The missing number is now equal to N - S.

Peter Chng on Jul 16, 2010

This post has been removed.
Please see our Community Guidelines or Terms of Service for more information.


xor all elements in the bucket -> A. now xor 1-3000 -> B. A xor B -> C. C is your answer

teitojin on Nov 9, 2010

Add Answers or Comments

To comment on this, Sign In or Sign Up.