Loading...
Loading...
Loading...
A sorted list holds distinct positive integers. The positive integers that are not in the list are called missing. Print the k-th missing positive integer.
Example
Input
5 5 2 3 4 7 11
Output
9
Try the problem first. Open one hint at a time.
At position i the number of missing values before a[i] is a[i] - (i + 1).
Find the first position where that count reaches k. The answer is then position + k.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor