values. Call its *opening run* the longest prefix in which each number is exactly 1 more than the one before it. The first element on its own also counts as a run.
Let s be the sum of the opening run. Return the smallest integer that is at least s and does not appear in values.values=[4, 5, 6, 9, 15, 16] → 17
The opening run is 4, 5, 6 with a sum of 15. Both 15 and 16 are in the array, 17 is not.
values=[2, 7, 3] → 4
The run is just the 2. Both 2 and 3 are present, but 4 is missing.
values=[1, 2, 3, 4] → 10
values=[4, 5, 6, 9, 15, 16]
17
Run checks the first 3 tests in your browser. Submit checks all 120 tests on the server, hidden ones included.