posted 20 years ago
Wouldn't that be a very big list? In fact, wouldn't it be an infinitely big list?
True. But since the list has already been sorted it's easy to find the smallest and largest number in the list; you can restrict things that way.
Even so, it seems a bit unnecessary to list all numbers in the range first. I'd just loop through the sorted list, comparing each element to the previous element. If the difference is greater than 1, you've got some missing numbers and ought to be able to determine what they are. Add them to the list of missing numbers, and continue looping through the original list.
Note that in this strategy, you will have to be a little careful at the beginning and end of the list, to make sure you don't accidentally refer to elements that don't exist. You may have to adjust the initial and exit conditions of the loop; they're not quite what you're used to seeing.
"I'm not back." - Bill Harding, Twister