Possible Duplicate:
Find the Smallest Integer Not in a List
An interview question. given a unsorted int array. How to find first int that bigger than 0 and not appears in that given array. for example:
input :[1,2,0]
output: 3
input [2,4,-1,1]
output: 3
I gave two solution
a) sort. Time C is: O(n), space C is O(1)
b) bitmap. Time Complexity :O(n), space O(n)
But interviewer doesn't satisfied. he said there is Time O(n) and constant space solution.
Any thought?
The resource is from my online friend.