Possible Duplicate:
Find the Smallest Integer Not in a List
you have a stream of unsorted positive integers. After you read all the numbers from the stream you have to determine the smallest positive integer that is missing from the stream.
example: Stream of positive integers: 6 7 8 9 1 2
ans : 3
Stream of positive integers: 1 2 3 4 5
and : 6
Stream of positive integers: 12 87 899
ans : 1
I wanted to solve the problem without taking any extra data structure. Is it possible?
I am stuck on this problem. Did all the research i could on the internet, but, no luck. Could anyone help.