274. Smallest Missing Positive
Print the smallest positive integer that does NOT appear among n integers.
Positive means 1 or greater, so the answer is at least 1.
3 4 -1 1 -> 2
1 2 0 -> 3
7 8 9 -> 1
Negatives, zeros and duplicates are all present in the input and none of them can be the answer.
Sort, then walk upwards looking for the first gap. Notice that the answer can
never exceed n + 1, because n values cannot cover more than n distinct
positives.
Constraints - `1 ≤ n ≤ 200000` - `-1000000000 ≤ a[i] ≤ 1000000000`
Input
The first line contains an integer n.
The second line contains n integers.
Output
Print one integer, the smallest positive integer not present.
Hints
Four rungs, in order. The last two open once you have submitted an attempt. A wrong one counts.