Let's say I have the continuous range of integers [0, 1, 2, 4, 6]
, in which the 3
is the first "missing" number. I need an algorithm to find this first "hole". Since the range is very large (containing perhaps 2^32
entries), efficiency is important. The range of numbers is stored on disk; space efficiency is also a main concern.
What's the best time and space efficient algorithm?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…