Find the missing number in one pass
Someone reads out the whole numbers from 1 to 100 in a random order, except that one number is left out. You hear the 99 numbers once each and cannot write them down; you may keep only a single running number in your head.
- How do you identify the missing number?
- Now suppose two numbers are missing. What two running quantities let you recover both?
Show a hint
You know what all 100 numbers add up to.
Your answer
Solving needs a free account
Answers, streaks and solutions unlock when you are signed in. Reading the question and the hint stays free.
Discussion
Sign in to join the discussion · reading is open to everyone
💡 Discussion rules
- No full solutions here. Hints and approaches only.
- Complexity, edge cases and intuition are the point.
- Interview experiences are welcome. Respect your NDAs.
Loading discussion…
Learn the concepts
The theory behind this question.
Related questions
Find the duplicated numberWriting 100 as a sum of consecutive numbersFinding one honest agent among liarsThe heaviest and the runner-up among eight coinsBoth the lightest and the heaviest of ten coins
All questions →