Loading...
Loading...
Loading...
Tickets are numbered 1, 2, 3, and so on, but some numbers in a list are missing. Find the smallest positive integer that does not appear in the list. The list may contain zero, negative numbers and repeats.
Example
Input
5 3 1 4 1 7
Output
2
1 is present, 2 is not.
Try the problem first. Open one hint at a time.
Put the values in a set so a lookup is quick.
Try 1, 2, 3, ... until one is not in the set. The answer is never larger than n + 1.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor